diff --git a/program 8.c b/program 8.c new file mode 100644 index 0000000..79c1ec7 --- /dev/null +++ b/program 8.c @@ -0,0 +1,164 @@ +#include +#include +int top=0; +struct stu +{ + char num[20]; + char c[20]; + char name[20]; + float m,p,e,s; +}stu[100]; + +void first() +{ + printf("1.input\n"); + printf("2.delete\n"); + printf("3.select\n"); + printf("4.order\n"); + printf("5.output\n"); + printf("6.quit\n"); + printf("please input your option\n"); +} + + +void a5() +{ + int i; + for(i=0;inum,key)==0||strcmp((stu+i)->name,key)==0) + { + d++;top--; + *(stu+i)=*(stu+i+d); + } + else + { + *(stu+i)=*(stu+i+d); + i++; + } + } + a5(); + printf("continue?\n"); + while(strcmp(n,"yes")!=0&&strcmp(n,"no")!=0);{ + scanf("%s",n); + } + if(strcmp(n,"no")==0) return; + } +} + +void a3() +{ + int i,flag; + char key[20],n[20]; + while(1) + { + flag=0; + scanf("%s",key); + for(i=0;inum,key)==0||strcmp((stu+i)->c,key)==0) + { + flag=1; + printf("%s,%s,%s,%.1f,%.1f,%.1f,%.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e,stu[i].s); + } + } + if(!flag) + { + printf("there is no eligible student\n"); + return; + } + printf("continue?\n"); + do{ + scanf("%s",n); + }while(strcmp(n,"yes")!=0&&strcmp(n,"no")!=0); + if(strcmp(n,"no")==0) return; + } +} + +void a4() +{ + int i,j; + struct stu t; + for(i=0;ic,(stu+j+1)->c)==1||strcmp((stu+j)->c,(stu+j+1)->c)==0&&((stu+j)->s<(stu+j+1)->s)) + { + t = *(stu+j); + *(stu+j) = *(stu+j+1); + *(stu+j+1) = t; + } + } + } + a5(); + return; +} + +int main() +{ + int n; + while(1) + { + first(); + scanf("%d",&n); + switch(n) + { + case(1): + a1(); + break; + case(2): + a2(); + break; + case(3): + a3(); + break; + case(4): + a4(); + break; + case(5): + a5(); + break; + case(6): + return 0; + } + } +} +