diff --git a/a6.c b/a6.c new file mode 100644 index 0000000..af62cfd --- /dev/null +++ b/a6.c @@ -0,0 +1,64 @@ +#include +#include +struct stu { + char num[6]; + char class[3]; + char name[6]; + float grade1; + float grade2; + float grade3; + float grade; +}s[10],ss; +int main() +{ + strcpy(s[0].num,"10001");strcpy(s[0].class,"11");strcpy(s[0].name,"Zhang");s[0].grade1=99.5;s[0].grade2=88.5;s[0].grade3=89.5;s[0].grade=s[0].grade1+s[0].grade2+s[0].grade3; + strcpy(s[1].num,"10002");strcpy(s[1].class,"12");strcpy(s[1].name,"Yang");s[1].grade1=77.9;s[1].grade2=56.5;s[1].grade3=87.5;s[1].grade=s[1].grade1+s[1].grade2+s[1].grade3; + strcpy(s[2].num,"10003");strcpy(s[2].class,"11");strcpy(s[2].name,"Liang");s[2].grade1=92.5;s[2].grade2=99.0;s[2].grade3=60.5;s[2].grade=s[2].grade1+s[2].grade2+s[2].grade3; + scanf("%s%s%s%f%f%f",s[3].num,s[3].class,s[3].name,&s[3].grade1,&s[3].grade2,&s[3].grade3); + s[3].grade=s[3].grade1+s[3].grade2+s[3].grade3; + for(int i=0;i<3;i++) + { + if(strcmp(s[i].num,s[3].num)==0) + { + s[i]=s[3]; + } + } + for(int i=0;i<2;i++) + { + for(int j=i+1;j<3;j++) + { + if(strcmp(s[i].class,s[j].class)>0) + { + ss=s[i]; + s[i]=s[j]; + s[j]=ss; + } + } + } + for(int i=0;strcmp(s[i].class,s[0].class)==0;i++) + { + for(int j=i+1;strcmp(s[j].class,s[0].class)==0;j++) + { + if(s[i].grade