解题思路:
注意事项:
参考代码:
#include<stdio.h>
struct student
{
char num[100];
char name[100];
int score1;
int score2;
int score3;
};
void input(int n,struct student stu[])
{
int i;
for(i=0;i<n;i++)
scanf("%s %s %d %d %d",stu[i].num,stu[i].name,&stu[i].score1,&stu[i].score2,&stu[i].score3);
}
int main()
{
struct student stu[100];
int n,i,sum1=0,sum2=0,sum3=0,a[100],max=0,k;
scanf("%d",&n);
input(n,stu);
for(i=0;i<n;i++)
{
sum1+=stu[i].score1;
sum2+=stu[i].score2;
sum3+=stu[i].score3;
a[i]=stu[i].score1+stu[i].score2+stu[i].score3;
if(a[i]>max)
{
max=a[i];
k=i;
}
}
sum1=sum1/n;
sum2=sum2/n;
sum3=sum3/n;
printf("%d %d %d\n",sum1,sum2,sum3);
printf("%s %s %d %d %d",stu[k].num,stu[k].name,stu[k].score1,stu[k].score2,stu[k].score3);
return 0;
}
0.0分
0 人评分