1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{ srand(time(0));
string wordList[10] = {
"What is 1+1?",
"What is 1+2?",
"What is 2+2?",
"What is 3+2?",
"What is 4+2?",
"What is 4+8?",
"What is 8+8?",
"What is 8+9?",
"What is 9+1?",
"What is 9+2?"};
const int answers[10] = {2,3,4,5,6,12,16,17,10,11};
int answer;
int quest;
quest = rand() %10;
string question = wordList[quest];
cout << question << endl;
cin >> answer;
if (answer == answers[quest])
cout << "That is incorrect" << endl;
else
cout << "Wrong!" << endl;
system ("pause");
return 0;
}
|