我是 C++ 初学者。我只想检查学生对一组答案键的答案。假设,我有一个学生,并且是这样声明的:
//Declare and array of student answers;
string student1 [] = {"A", "B", "C", "A", "B","C","A","B","A","A"};
答案键是这样声明的:
//Declare an array set of answer key
string keys [] = {"A", "B", "C", "A", "B","C","A","B","A","A"};
想象一下答案键是 1 - 10 问题的正确答案。然后我想检查学生的答案是否与声明的答案键匹配:
for(const string &key : keys){
for(const string &answer : answers){
if(key == answer){
cout << "Correct" << endl;
}else{
cout << "Wrong" << endl;
}
}
}
我的第一个问题是,它给了我以下结果:
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
第二个是,我想再添加 5 个学生来检查他们的答案。谢谢。