diff --git a/README.md b/README.md index 5e55ea3..02615d7 100644 --- a/README.md +++ b/README.md @@ -480,5 +480,178 @@ scanf("%d",&changer1); } return 0; } +步骤八 +#include +struct student{ + int id; + int class; + char name[20]; + double score1; + double score2; + double score3; + double score; +}stu[7]; +void xunwen(void){ + printf("1.input\n"); + printf("2.delet\n"); + printf("3.select\n"); + printf("4.order\n"); + printf("5.output\n"); + printf("6.quit\n"); + printf("please input your option\n"); +} +void input(void){ + int i,j; + char str[3]; + void zhixing(void); + for(i=0;i<7;i++){ + printf("id "); + scanf("%d",&stu[i].id); + printf("class "); + scanf("%d",&stu[i].class); + printf("name "); + scanf("%s",stu[i].name); + printf("score1 "); + scanf("%lf",&stu[i].score1); + printf("score2 "); + scanf("%lf",&stu[i].score2); + printf("score3 "); + scanf("%lf",&stu[i].score3); + printf("continue?\n"); + scanf("%s",str); + if(str[0]=='y') + continue; + else if(str[0]=='n') + break; + else + return; + } + for(i=0;i<7;i++){ + stu[i].score=stu[i].score1+stu[i].score2+stu[i].score3; + } + xunwen(); + zhixing(); +} +void delet(struct student stu4[]){ + void xunwen(void); + void zhixing(void); + int i,j,k,a,b,c; + char str[3]; + scanf("%d",&a); + for(i=0;i<7;i++){ + if(stu[i].id==a){ + stu[i].id=0; + } + } + for(i=0;i<7;i++){ + if(stu[i].id!=0) + printf("%d %d %s %.1f %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); + } + printf("continue?\n"); + struct student *p=stu; + scanf("%s",str); + if(str[0]=='y') + delet(p); + else if(str[0]=='n') + xunwen(); + zhixing(); +} +void select(struct student stu7[]){ + void xunwen(void); + void zhixing(void); + int i,j,k,a,b,c=1; + char str[3]; + scanf("%d",&a); + if(a>100){ + for(i=0;i<7;i++){ + if(stu7[i].id==a) + printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); + c=0; + } + } + else if(a<100){ + for(i=0;i<7;i++){ + if(stu7[i].class==a){ + printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); + c=0; + } + } + } + if(c==1) + printf("there is no eligible student"); + printf("continue?\n"); + struct student *p=stu; + scanf("%s",str); + if(str[0]=='y'){ + select(p); + } + else if(str[0]=='n'){ + xunwen(); + zhixing(); + } +} +void order(struct student stu2[]){ + void zhixing(void); + void output(void); + int i,j,k=0,a,b,c; + struct student temp; + struct student stu1[7]; + for(i=0;i<7;i++){ + stu1[i]=stu2[i]; + } + for(i=0;i<6;i++){ + for(j=i+1;j<7;j++){ + if(stu1[j].score>=stu1[i].score){ + temp=stu1[i]; + stu1[i]=stu1[j]; + stu1[j]=temp; + } + } + } + for(i=1;i<30;i++){ + for(j=0;j<7;j++){ + if(stu1[j].class==i) + stu2[k++]=stu1[j]; + } + } + for(i=0;i<7;i++){ + if(stu[i].id!=0){ + printf("%d %s %d %.1f %.1f %.1f",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3); + } + } + xunwen(); + zhixing(); +} +void output(){ + void zhixing(void); + int i; + for(i=0;i<7;i++){ + if(stu[i].id!=0) + printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); + } + xunwen(); + zhixing(); +} +void quit(void){ + return; +} +void zhixing(void){ + int i; + scanf("%d",&i); + struct student *p=stu; + switch(i){ + case 1:input();break; + case 2:delet(p);break; + case 3:select(p);break; + case 4:order(p);break; + case 5:output();break; + case 6:quit();break; + } +} +int main(){ + xunwen(); + zhixing(); + return 0; +}