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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include <iostream>
using namespace std;
int main()
{
const int numbStudents = 8;
const int numbQuestions = 10;
int StudentsMarktemp[numbStudents];
//Students' answers to the questions
char answers[numbStudents][numbQuestions] =
{
{'A','B','A','C','C','D','E','E','A','D'},
{'D','B','A','B','C','A','E','E','A','D'},
{'E','D','D','A','C','B','E','E','A','D'},
{'C','B','A','E','D','C','E','E','A','D'},
{'A','B','D','C','C','D','E','E','A','D'},
{'B','B','E','C','C','D','E','E','A','D'},
{'B','B','A','C','C','D','E','E','A','D'},
{'E','B','E','C','C','D','E','E','A','D'},
};
//Key to the questions
char keys[] = {'D','B','D','C','C','D','A','E','A','D'};
//Grade all answers
for (int i = 0; i < numbStudents; i++)
{
//Grade one student
int correctCount = 0;
for (int j = 0; j < numbQuestions; j++)
{
if (answers[i][j] == keys[j])
correctCount++;
}
StudentsMarktemp[i] = correctCount;
}
int temp = 0;
int k=0;
int max =0;
while (k!=8)
{
temp =0;
max = StudentsMarktemp[0];
for (int j=0;j<numbStudents;j++)
{
if ((max<StudentsMarktemp[j]))
{
max = StudentsMarktemp[j];
temp = j;
}
}
cout << "Student " << temp << "'s correct count is " << StudentsMarktemp[temp] << endl;
StudentsMarktemp[temp] =-1;
k++;
}
getchar();
return 1;
}
|