#include<stdio.h> struct stu{ char num[100]; char name[100]; int score[3]; }; void input(struct stu *a,int n); void output(struct stu *a,int n); int main(){ int n; scanf("%d",&n); struct stu a[n]; input(a,n); output(a,n); return 0; } void input(struct stu *a,int n){ int i; for(i=0;i<n;i++){ scanf("%s%s%d%d%d",&(a[i].num),&(a[i].name), &(a[i].score[0]),&(a[i].score[1]),&(a[i].score[2])); } } void output(struct stu *a,int n){ int i,j,t1,t2,max; max = a[1].score[0]; int ave0=0,ave1=0,ave2=0; for(i=0;i<n;i++){ ave0 += a[i].score[0]; ave1 += a[i].score[1]; ave2 += a[i].score[2]; for(j=0;j<3;j++){ if(max <= a[i].score[j]){ max = a[i].score[j]; t1 = i; } } } printf("%d %d %d\n",ave0/n,ave1/n,ave2/n); printf("%s %s %d %d %d\n",a[t1].num,a[t1].name,a[t1].score[0], a[t1].score[1],a[t1].score[2]); }
解题思路:
注意事项:
参考代码:
0.0分
1 人评分