diff --git a/8.cpp b/8.cpp new file mode 100644 index 0000000..ae23f68 --- /dev/null +++ b/8.cpp @@ -0,0 +1,200 @@ +#include +#include +#include +#include +void input(); +void delete1(); +void select(); +void order(); +void output(); +void output1(); +void quit(); +void menu(); +int sum=0; + +struct stu +{ + int Id; + int clas; + char name[100]; + float score1; + float score2; + float score3; + float score; +}stu[1000]; +int main() +{ + while(1) + { + 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("class "); + scanf("%d",&stu[sum].clas); + printf("name "); + scanf("%s",&stu[sum].name); + printf("score1 "); + scanf("%f",&stu[sum].score1); + printf("score2 "); + scanf("%f",&stu[sum].score2); + printf("score3 "); + scanf("%f",&stu[sum].score3); + stu[sum].score=stu[sum].score3+stu[sum].score2+stu[sum].score1; + printf("continue?\n"); + char a[10]; + scanf("%s",&a); + if(a[0]=='y'&&a[1]=='e'&&a[2]=='s') + { + input(); + } + else if(a[0]=='n'&&a[1]=='o') + { + menu(); + } +} +void delete1() +{ + printf("please input the id or name of the deleted person\n"); + char b[100]; + scanf("%s",&b); + int c=-56356,f=1,len1,len=strlen(b); + if(b[0]>'0'&&b[0]<'0') + { + for(int k=0;k1) + { + for(int i=1;i<=sum;i++) + { + f=1; + len1=strlen((stu[i].name)); + for(int x=0;xstu[j].clas) + { + stu[sum+1]=stu[i]; + stu[i]=stu[j]; + stu[j]=stu[sum+1]; + } + 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+1]; + } + } + } + } +} +void output() +{ + for(int i=1;i<=sum;i++) + { + printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); + } + menu(); +} +void output1() +{ + for(int i=1;i<=sum;i++) + { + printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); + } +} +void quit() +{ + exit(0); +} +