#include<stdio.h> #include<stdlib.h> struct stu{ char a[10]; char b[10];a float s1; float s2; float s3; }; int main() { struct stu student[10]; int i,j,n; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s%s%f%f%f",&student[i].a,&student[i].b,&student[i].s1,&student[i].s2,&student[i].s3); } int sum1=0,sum2=0,sum3=0; for(i=0;i<n;i++) { sum1=sum1+student[i].s1+student[i].s2+student[i].s3; printf("%.0f ",sum1/3); } int j,h=student[0].s1+student[0].s2+student[0].s3; for(i=1;i<n;i++) { if (h<(student[i].s1+student[i].s2+student[i].s3)) { j=i; h=student[i].s1+student[i].s2+student[i].s3); } } // printf("%.0f %.0f %.0f\n",avg1,avg2,avg3); printf("%s %s %.0f %.0f %.0f\n",student[j].a,student[j].b,student[j].s1,student[j].s2,student[j].s3); return 0; } /* Main.c:5:13: error: expected specifier-qualifier-list before 'a' char b[10];a ^ Main.c: In function 'main': Main.c:17:61: error: 'struct stu' has no member named 's1' scanf("%s%s%f%f%f",&student[i].a,&student[i].b,&student[i].s1,&student[i].s2,&student[i].s3); ^ Main.c:17:76: error: 'struct stu' has no member named 's2' scanf("%s%s%f%f%f",&student[i].a,&student[i].b,&student[i].s1,&student[i].s2,&student[i].s3); ^ Main.c:17:91: error: 'struct stu' has no member named 's3' scanf("%s%s%f%f%f",&student[i].a,&student[i].b,&student[i].s1,&student[i].s2,&student[i].s3); ^ Main.c:22:23: error: 'struct stu' has no member named 's1' sum1=sum1+student[i].s1+student[i].s2+student[i].s3; ^ Main.c:22:37: error: 'struct stu' has no member named 's2' sum1=sum1+student[i].s1+student[i].s2+student[i].s3; ^ Main.c:22:51: error: 'struct stu' has no member named 's3' sum1=sum1+student[i].s1+student[i].s2+student[i].s3; ^ Main.c:23:3: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=] printf("%.0f ",sum1/3); ^ Main.c:25:6: error: redeclaration of 'j' with no linkage int j,h=student[0].s1+student[0].s2+student[0].s3; ^ Main.c:13:8: note: previous declaration of 'j' was here int i,j,n; ^ Main.c:25:20: error: 'struct stu' has no member named 's1' int j,h=student[0].s1+student[0].s2+student[0].s3; ^ Main.c:25:34: error: 'struct stu' has no member named 's2' int j,h=student[0].s1+student[0].s2+student[0].s3; ^ Main.c:25:48: error: 'struct stu' has no member named 's3' int j,h=student[0].s1+student[0].s2+student[0].s3; ^ Main.c:28:20: error: 'struct stu' has no member named 's1' if (h<(student[i].s1+student[i].s2+student[i].s3)) ^ Main.c:28:34: error: 'struct stu' has no member named 's2' if (h<(student[i].s1+student[i].s2+student[i].s3)) ^ Main.c:28:48: error: 'struct stu' has no member named 's3' if (h<(student[i].s1+student[i].s2+student[i].s3)) ^ Main.c:31:16: error: 'struct stu' has no member named 's1' h=student[i].s1+student[i].s2+student[i].s3); } ^ Main.c:31:30: error: 'struct stu' has no member named 's2' h=student[i].s1+student[i].s2+student[i].s3); } ^ Main.c:31:44: error: 'struct stu' has no member named 's3' h=student[i].s1+student[i].s2+student[i].s3); } ^ Main.c:31:47: error: expected ';' before ')' token h=student[i].s1+student[i].s2+student[i].s3); } ^ Main.c:31:47: error: expected statement before ')' token Main.c:34:73: error: 'struct stu' has no member named 's1' printf("%s %s %.0f %.0f %.0f\n",student[j].a,student[j].b,student[j].s1,student[j].s2,student[j].s3); ^ Main.c:34:87: error: 'struct stu' has no member named 's2' printf("%s %s %.0f %.0f %.0f\n",student[j].a,student[j].b,student[j].s1,student[j].s2,student[j].s3); ^ Main.c:34:101: error: 'struct stu' has no member named 's3' printf("%s %s %.0f %.0f %.0f\n",student[j].a,student[j].b,student[j].s1,student[j].s2,student[j].s3); ^ Main.c:19:20: warning: unused variable 'sum3' [-Wunused-variable] int sum1=0,sum2=0,sum3=0; ^ Main.c:19:13: warning: unused variable 'sum2' [-Wunused-variable] int sum1=0,sum2=0,sum3=0; ^ */ |
Double click to view unformatted code.