diff --git a/a5.c b/a5.c new file mode 100644 index 0000000..b0fab4d --- /dev/null +++ b/a5.c @@ -0,0 +1,96 @@ +#include +#include +struct stu { + char num[6]; + int class; + char name[6]; + float grade1; + float grade2; + float grade3; + float grade; +}s[10],ss; +int main() +{ + strcpy(s[0].num,"10001");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");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");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; + char z[6]; + scanf("%s",z); + int a=0,m; + for(int i=0;i<3;i++) + { + if(strcmp(z,s[i].name)==0||strcmp(z,s[i].num)==0) + { + m=i; + a=1; + break; + } + } + if(a==1) + { + if(m<=1) + { + for(int j=m;j<2;j++) + { + s[j]=s[j+1]; + } + } + for(int i=0;i<1;i++) + { + ss=s[i]; + for(int j=i+1;j<2;j++) + { + if(s[i].grade