解题思路:
注意事项:
参考代码:
#include<stdio.h> struct student { char sno[20]; char sname[20]; int cj1; int cj2; int cj3; }; void input(struct student st[],int n) { int i; for(i = 0; i < n; i++){ scanf("%s%s%d%d%d",&st[i].sno,&st[i].sname,&st[i].cj1,&st[i].cj2,&st[i].cj3); } } void print(struct student st[],int n) { int i,k,sum = 0; for(i = 0; i < n; i++){ if(st[i].cj1 + st[i].cj2 + st[i].cj3 > sum){ sum = st[i].cj1 + st[i].cj2 + st[i].cj3; k = i; } } printf("%s %s %d %d %d\n",st[k].sno,st[k].sname,st[k].cj1,st[k].cj2,st[k].cj3); } int main() { int N,i,avg1 = 0,avg2 = 0,avg3 = 0; struct student st[100]; scanf("%d",&N); input(st,N); for(i = 0; i < N; i++){ avg1 += st[i].cj1; avg2 += st[i].cj2; avg3 += st[i].cj3; } printf("%d %d %d\n",avg1/N,avg2/N,avg3/N); print(st,N); return 0; }
0.0分
0 人评分