#include<stdio.h> #include<math.h> #include<string.h> struct student { char name[20]; int height; int money; }; void main(){ struct student stu[1000]; int n,a,count1=0,count2=0; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%s %d %d",&stu[i].name,&stu[i].height,&stu[i].money); for(int j=0;j<n;j++) if(strcmp(stu[j].name,"Suxiao")==0) {a=i;break;} for(int m=0;m<n;m++){ if(stu[a].height>stu[m].height)count1++; if(stu[a].money>stu[m].money)count2++; } if(count1>count2) printf("HEIGHT"); if(count1<count2) printf("MONEY"); if(count1==count2) printf("EQ"); } /* Main.c:10:6: warning: return type of 'main' is not 'int' [-Wmain] void main(){ ^ Main.c: In function 'main': Main.c:15:3: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[20]' [-Wformat=] scanf("%s %d %d",&stu[i].name,&stu[i].height,&stu[i].money); ^ Main.c:18:6: error: 'i' undeclared (first use in this function) {a=i;break;} ^ Main.c:18:6: note: each undeclared identifier is reported only once for each function it appears in */ |
Double click to view unformatted code.