#include<stdio.h> #include<math.h> struct student { char mum[100]; char nam[100]; int a,b,c; }stu; int main(){ struct student stu[100]; int n,i,j=0,ave1=0,ave2=0,ave3=0,max1=0,max2=0,max3=0; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s %s %d %d %d",&stu[i].num,&stu[i].nam,&stu[i].a,&stu[i].b,&stu[i].c); ave1=ave1+stu[i].a; ave2=ave2+stu[i].b; ave3=ave3+stu[i].c; } ave1=ave1/n; ave2=ave2/n; ave3=ave3/n; printf("%d %d %d\n",ave1,ave2,ave3); for(i=0;i<n;i++) if(max1<stu[i].a&&max2<stu.[i].b&&max3<stu[i].c){ max1=stu[i].a; max2=stu[i].b; max3=stu[i].c; j=i; } printf("%s %s %d %d %d ",stu[j].num,stu[j].nam,stu[j].a,stu[j].b,stu[j].c); return 0; } /* Main.c: In function 'main': Main.c:14:35: error: 'struct student' has no member named 'num' scanf("%s %s %d %d %d",&stu[i].num,&stu[i].nam,&stu[i].a,&stu[i].b,&stu[i].c); ^ Main.c:24:32: error: expected identifier before '[' token if(max1<stu[i].a&&max2<stu.[i].b&&max3<stu[i].c){ ^ Main.c:30:34: error: 'struct student' has no member named 'num' printf("%s %s %d %d %d ",stu[j].num,stu[j].nam,stu[j].a,stu[j].b,stu[j].c); ^ Main.c:11:50: warning: variable 'max3' set but not used [-Wunused-but-set-variable] int n,i,j=0,ave1=0,ave2=0,ave3=0,max1=0,max2=0,max3=0; ^ */ |
Double click to view unformatted code.