I am trying to create a board that looks like this where every number that is di
ID: 3908942 • Letter: I
Question
I am trying to create a board that looks like this where every number that is divisible by 9 is the same letter. For example for the first board every number that is divisble by 9 will be letter X.
After refreshing to a new board, every number that is divisble by 9 will be a different letter such as letter Z.
I was able to create the board with random letters throughout but was not able to add the condition I stated above to my board. Please help
99y 98:B 97 : ? 96:m 95:e 94:X 93:X 92 : g 91:a 90:y 89:N 88: s 87:P 86:s 85:u 84:0 83:i 82:X 81:y 80:k 79:m 78:y 77:T 76:0 75 : N 74:Z 73:N 72:y 71:X 70:s 69:? 68:aj 67:a 66:D 65 :D 64 : F 63:y 62 : N 61 :J 60 . P 59:P 58:c 57:i 56:Z 55:X 54:y 53 :m 52:i 51:N 50:P 49:e 48:e 47:X 46:D 45:? 44:e 43.a 42:R 41:T 40. ? 39:P 38: F 37:g 36:y 35:F 34 :u 33:H 32 :m 31:D 30:H 29:D 28:0 27:y 26:e 25:H 24:0 23:m 22 : F 21 :X 20:i 19:L 18:y 17:w 16:N 15:k 14:P 13:B 12:o 11:X 10:JExplanation / Answer
#include<iostream>
#include<string>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main(){
srand(time(NULL));
string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
while (true){
int a = rand() % 52;
for (int i = 99; i>=0; i++){
if (i % 9 != 0){
int n = rand() % 52;
cout << i << ":" << str[n] << " ";
}
else {
cout << i << ":" << str[a] << " ";
}
if (i % 10 == 0)
cout << endl;
}
cout << "Continue(y/n)?:" << endl;
string ch;
cin >> ch;
if (ch[0] =='n')
break;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.