diff --git a/step8 b/step8 new file mode 100644 index 0000000..42c3258 --- /dev/null +++ b/step8 @@ -0,0 +1,162 @@ +#include +#include +struct Student +{ + char id[20]; + char Class[20]; + char name[50]; + float gs; + float dw; + float yy; + float all; +}; +struct Student stu[20]; +int n=0; +void menu() +{ + printf("1.input\n"); + printf("2.delect\n"); + printf("3.select\n"); + printf("4.order\n"); + printf("5.output\n"); + printf("6.quit\n"); + printf("please input your optition\n"); +} +void print() +{ + int i=0; + for(i;iid,key)==0||strcmp((stu+i)->name,key)==0) + { + d++;n--; + *(stu+i)=*(stu+i+d); + } + else + { + *(stu+i)=*(stu+i+d); + i++; + } + } + print(); + printf("continue?\n"); + do{ + scanf("%s",op); + }while(strcmp(op,"yes")!=0&&strcmp(op,"no")!=0); + if(strcmp(op,"no")==0) return; + } +} + +void select() +{ + int i,j; + char key[20],op[20]; + while(1) + { + j=0; + scanf("%s",key); + for(i=0;iid,key)==0||strcmp((stu+i)->Class,key)==0) + { + j=1; + printf("%s,%s,%s,%.1f,%.1f,%.1f,%.1f\n",stu[i].id,stu[i].Class,stu[i].name,stu[i].gs,stu[i].dw,stu[i].yy,stu[i].all); + } + } + if(j==0) + { + printf("there is no eligible student\n"); + return; + } + printf("continue?\n"); + do + { + scanf("%s",op); + } + while(strcmp(op,"yes")!=0&&strcmp(op,"no")!=0); + if(strcmp(op,"no")==0) return; + } +} +void order() +{ + int i,j; + struct Student swap; + for(i=0;iClass,(stu+j+1)->Class)==1||(strcmp((stu+j)->Class,(stu+j+1)->Class)==0)&&stu[j].all