⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 10v.cpp

📁 《C/C++程序设计导论(第二版)》一书的程序源文件
💻 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 + -