📄 10v.cpp
字号:
// GradeStudents () Using the `answers' test key, grade
// each student quiz in file STUDENTFILE. Print score.
// ASSUMPTION: file STUDENTFILE exists and contains
// one record per student.
// IN: studfile is a string file name
// answers contains (size) test key answers
// size is the size of the answers and summary arrays
// OUT: summary will be a count table of correct answers.
void GradeStudents (string studfile, char answers[ ],
int summary[ ], int size)
{ ifstream studentfile_in (studfile, ios::in);
int id, score, ans;
char thisanswer;
while (studentfile_in >> id) // loop over students
{ score = 0; // assume a zero score
for (ans=0; ans<size; ans++) // loop over answers
{ studentfile_in >> thisanswer; // get next answer
if (thisanswer==answers[ans]) // is it right?
{ score++; // if so, update grade
summary[ans]++; // and tabulate
}
} // end of loop over answers (ans)
cout << "student: "<< id <<" score: " << score << endl;
} // end of loop over students
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -