好的,所以我有点被困在这里,真的不知道下一步该做什么。假设用户输入一系列关键答案(AD),然后让多个学生(数量取决于用户输入)输入他们自己的答案,程序应该将他们的答案与之前输入的答案键进行比较并对每个学生进行评分分别。现在我的问题是,如何将每个学生的答案与数组中的答案键进行比较?到目前为止,这是我的代码
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int NumOfQ;
int NumOfS;
char TestAns[50];
string StudentNames[50];
int StudentScores[50];
char StudentAns[50];
int score[50];
cout << "Please enter the Number Of Questions\n";
cin >> NumOfQ;
cout <<"\nPlease enter your answers\n";
for(int x = 0; x < NumOfQ; x++){
cin >> TestAns[x];
}
cout <<"\nPlease enter number of students\n";
cin >> NumOfS;
cout <<"\nPlease enter Student's Names\n";
for (int s = 0; s < NumOfS; s++){
cin >> StudentNames[s];
}
for (int z = 0; z < NumOfS; z++){
cout<<"\nStudent: " << StudentNames[z] << " Please enter your test answers\n";
for (int a = 0; a < NumOfQ; a++){
cin >> StudentAns[a];
}
score[z] = 0;
for (int i = 0; i <=NumOfQ; i++){
if(TestAns[i] == StudentAns[i]){
score[z]++;
}
}
}
for(int Z = 0; Z < NumOfS; Z++){
cout <<"\Student : " << StudentNames[Z] << score[Z] << " out of " << NumOfQ << endl;
}
system("PAUSE");
return 0;
}