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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <iostream>
using namespace std;
int main()
{
const int size = 20;
char answer[size];
char key[size] = {'A','D','B','B','C','B','A','B','C','D','A','C','D','B','D','C','C','A','D','B' };
static int score = 0;
int wrong[size];
for (int i = 0; i < size; i++)
{
cout << "Question " << i + 1 << ": ";
cin >> answer[i];
while (answer[i] != 'A' && answer[i] != 'B' && answer[i] != 'C' && answer[i] != 'D')
{
cout << "Enter valid answer: " << ": ";
cin >> answer[i];
}
if (answer[i] == key[i])
{
score += 1;
}
else
wrong[i] = i;
}
if (score < 15)
{
cout <<"You didn't pass." << endl;
}
else
{
cout << "Congratulations, you passed!" << endl;
}
cout << "You missed the following questions: \n " << wrong <<".\n";
return 0;
}
|