#include<stdio.h> struct Student{ char name[20]; int height; int momey; }; int main(){ int n; scanf("%d",&n); Student stu[n]; int index; for(int i=0;i<n;i++){ scanf("%s%d%d",&stu[i].name,&stu[i].height,&stu[i].momey); if(stu[i].name=="Suxiao"){ index=i; } } //先找到苏晓是第几个学生 int shengao=0; int qian=0; for(int i=0;i<n;i++){ if(stu[index].height<=stu[i].height){ shengao++; } if(stu[index].momey<=stu[i].momey){ qian++; } } if(shengao>qian){ printf("HEIGHT "); }else if(shengao<qian){ printf("MONEY"); }else{ printf("EQ"); } return 0; } /* Main.c: In function 'main': Main.c:10:2: error: unknown type name 'Student'; use 'struct' keyword to refer to the type Student stu[n]; ^~~~~~~ struct Main.c:13:25: error: request for member 'name' in something not a structure or union scanf("%s%d%d",&stu[i].name,&stu[i].height,&stu[i].momey); ^ Main.c:13:38: error: request for member 'height' in something not a structure or union scanf("%s%d%d",&stu[i].name,&stu[i].height,&stu[i].momey); ^ Main.c:13:53: error: request for member 'momey' in something not a structure or union scanf("%s%d%d",&stu[i].name,&stu[i].height,&stu[i].momey); ^ Main.c:14:12: error: request for member 'name' in something not a structure or union if(stu[i].name=="Suxiao"){ ^ Main.c:22:16: error: request for member 'height' in something not a structure or union if(stu[index].height<=stu[i].height){ ^ Main.c:22:31: error: request for member 'height' in something not a structure or union if(stu[index].height<=stu[i].height){ ^ Main.c:25:16: error: request for member 'momey' in something not a structure or union if(stu[index].momey<=stu[i].momey){ ^ Main.c:25:30: error: request for member 'momey' in something not a structure or union if(stu[index].momey<=stu[i].momey){ ^ Main.c:10:10: warning: variable 'stu' set but not used [-Wunused-but-set-variable] Student stu[n]; ^~~ */ |
Double click to view unformatted code.