成绩处理

#include <fstream>
#include <iostream>
using namespace std;
struct Score
{
	char num[13]; 
	char name[14];
	int cpp;
	int math;
	int english;
};
int main()
{    
	int i,n=0;
	Score score[300];
	ifstream infile("score.txt",ios::in);
	if(!infile)
	{
		cerr<<"open error!"<<endl;
		exit(1);
	}
	while(!infile.eof())
	{
		infile>>score[n].num>>score[n].name>>score[n].cpp>>score[n].math>>score[n].english;
		++n;
	}
	infile.close();
	for(i=0;i<n-1;i++)
	{
		
		cout<<score[i].num<<"   "<<score[i].name<<"   "<<score[i].cpp<<"    "<<score[i].math<<"    "<<score[i].english<<endl;
	}
	return 0;
}

你可能感兴趣的:(成绩处理)