diff --git a/8.cpp b/8.cpp new file mode 100644 index 0000000..f957990 --- /dev/null +++ b/8.cpp @@ -0,0 +1,181 @@ +#include +#include +#include +#include +void input(); +void delete1(); +void select(); +void order(); +void output(); +void quit(); +void menu(); +int sum=0; + +struct stu +{ + int Id; + int clas; + char name[10]; + double score1; + double score2; + double score3; + double score; +}stu[1000]; +int main() +{ + while(1) + { + void menu(); + } +} +void menu() +{ + 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"); + int t; + scanf("%d",&t); + switch(t) + { + case 1:input();break; + case 2:delete1();break; + case 3:select();break; + case 4:order();break; + case 5:output();break; + case 6:quit();break; + } +} +void input() +{ + sum=sum+1; + printf("Id "); + scanf("%d",&stu[sum].Id); + printf("\n"); + printf("class "); + scanf("%d",stu[sum].clas); + printf("\n"); + printf("name "); + scanf("%s",&stu[sum].name); + printf("\n"); + printf("score1 "); + scanf("%f",&stu[sum].score1); + printf("\n"); + printf("score2 "); + scanf("%f",&stu[sum].score2); + printf("\n"); + printf("score3 "); + scanf("%f",&stu[sum].score3); + printf("\n"); + printf("continue?\n"); + char a[10]; + scanf("%s",&a); + if(a[0]=='y'&&a[1]=='e'&&a[2]=='s') + { + delete1(); + } + else if(a[0]=='n'&&a[1]=='o') + { + menu(); + } +} +void delete1() +{ + char b[10]; + scanf("%s",&b); + int c=0,len=strlen(b); + for(int k=0;k1) + { + for(int i=1;i<=sum;i++) + { + if(stu[i].Id==c||stu[i].name==b) + { + for(int j=i;j<=sum;j++) + { + stu[j]=stu[j+1]; + sum=sum-1; + } + } + } + } + else + { + printf("ÎÞ·¨É¾³ý"); + } + output(); + char a[10]; + scanf("%s",&a); + if(a[0]=='y'&&a[1]=='e'&&a[2]=='s') + { + delete1(); + } + else if(a[0]=='n'&&a[1]=='o') + { + menu(); + } +} +void select() +{ + int b; + scanf("%d",&b); + for(int i=1;i<=sum;i++) + { + if(stu[i].Id==b||stu[i].clas==b) + { + printf("%s %s %s %f %f %f %f",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score1+stu[i].score2+stu[i].score3) ; + } + } + char a[10]; + scanf("%s",&a); + if(a[0]=='y'&&a[1]=='e'&&a[2]=='s') + { + delete1(); + } + else if(a[0]=='n'&&a[1]=='o') + { + menu(); + } +} +void order() +{ + for(int i=1;i<=sum;i++) + { + for(int j=i;j<=sum;j++) + { + if(stu[i].clas>stu[j].clas) + { + stu[sum+1]=stu[i]; + stu[i]=stu[j]; + stu[j]=stu[sum]; + } + else if(stu[i].clas==stu[j].clas) + { + if(stu[i].Id>stu[j].Id) + { + stu[sum+1]=stu[i]; + stu[i]=stu[j]; + stu[j]=stu[sum]; + } + } + } + } +} +void output() +{ + for(int i=1;i<=sum;i++) + { + printf("%s %s %s %f %f %f %f",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score1+stu[i].score2+stu[i].score3); + } + menu(); +} +void quit() +{ + exit(0); +}