解题思路:
注意事项:
参考代码:
#include<iostream>
using namespace std;
struct student{
string id;
string name;
int a,b,c;
int sum;
};
int main()
{
struct student stu[20];
int n;
int sum1[3]={0};
int m=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>stu[i].id>>stu[i].name>>stu[i].a>>stu[i].b>>stu[i].c;
sum1[0]+=stu[i].a;
sum1[1]+=stu[i].b;
sum1[2]+=stu[i].c;
stu[i].sum=stu[i].a+stu[i].b+stu[i].c;
}
for(int i=0;i<3;i++){
cout<<sum1[i]/n<<" ";
}
cout<<endl;
for(int i=0;i<n;i++){
int max = stu[0].sum;
if(stu[i].sum>max){
max = stu[i].sum;
m = i;
}
}
cout<<stu[m].id<<" "<<stu[m].name<<" "<<stu[m].a<<" "<<stu[m].b<<" "<<stu[m].c<<endl;
return 0;
}
0.0分
0 人评分