结构体 弄成绩统计比较好
#include <iostream>
using namespace std;
struct Student
{
char num[13];
char name[10];
int cpp;
int math;
int english;
int grade;
double average;
};
const int N=3;
int main( )
{
int i;
Student stu[5];
for(i=0;i<5;i++)
{cin>>stu[i].num;
cin>>stu[i].name;
cin>>stu[i].cpp;
cin>>stu[i].math;
cin>>stu[i].english;
stu[i].grade=stu[i].cpp+stu[i].math+stu[i].english;
stu[i].average=stu[i].grade/N;
cout<<stu[i].grade<<endl;
cout<<stu[i].average<<endl;}
return 0;
}
using namespace std;
struct Student
{
char num[13];
char name[10];
int cpp;
int math;
int english;
int grade;
double average;
};
const int N=3;
int main( )
{
int i;
Student stu[5];
for(i=0;i<5;i++)
{cin>>stu[i].num;
cin>>stu[i].name;
cin>>stu[i].cpp;
cin>>stu[i].math;
cin>>stu[i].english;
stu[i].grade=stu[i].cpp+stu[i].math+stu[i].english;
stu[i].average=stu[i].grade/N;
cout<<stu[i].grade<<endl;
cout<<stu[i].average<<endl;}
return 0;
}