From 149fb64c2a4c8bb683e5076fc6dd41b7fdc3e8a6 Mon Sep 17 00:00:00 2001 From: pqfc6e4lh <407900437@qq.com> Date: Sat, 11 Nov 2023 00:03:34 +0800 Subject: [PATCH] ADD file via upload --- 步骤8(修改中).c | 252 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 步骤8(修改中).c diff --git a/步骤8(修改中).c b/步骤8(修改中).c new file mode 100644 index 0000000..4340508 --- /dev/null +++ b/步骤8(修改中).c @@ -0,0 +1,252 @@ +#include +#include +#include +int len=0; +struct Student/*½á¹¹Ìå³¢ÊÔ*//*È«¾Ö±äÁ¿*/ +{ + char id[200]; + int clas; + char name[200]; + double a; + double b; + double c; + double d; +}stu[10001]; +int main() +{ + void print(); + void input(); + void delet(); + void selecting(); + void order(); + void sortclass(); + void sortexam(int,int); + void judge(); + void menuprint(); + menuprint(); +return 0; +} +void print()/*´òÓ¡³ÌÐò*/ +{ + int i; + for(i=1;i<=len;i++) + printf("%s,%d,%s,%.1lf,%.1lf,%.1lf,%.1lf\n",stu[i].id,stu[i].clas,stu[i].name,stu[i].a,stu[i].b,stu[i].c,stu[i].d); +} +void judge() +{ + void print(); + void input(); + void delet(); + void selecting(); + void order(); + void sortclass(); + void sortexam(int,int); + void judge(); + void menuprint(); + int t; + scanf("%d",&t); + if(t==1) + input(); + else if(t==2) + delet(); + else if(t==3) + selecting(); + else if(t==4) + order(); + else if(t==5) + { + print(); + menuprint(); +} + else if(t!=6) + { + printf("Wrong input\nplease input again\n"); + menuprint(); + } +} + +void menuprint() +{ + 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"); + judge(); +} + +void input()/*ÊäÈë³ÌÐò*/ +{ + char e[1001]; + len++; + printf("Id "); + scanf("%s",&stu[len].id); + + printf("class "); + scanf("%d",&stu[len].clas); + printf("name "); + scanf("%s",&stu[len].name); + printf("score1 "); + scanf("%lf",&stu[len].a); + printf("score2 "); + scanf("%lf",&stu[len].b); + printf("score3 "); + scanf("%lf",&stu[len].c); + stu[len].d=stu[len].a+stu[len].b+stu[len].c; + printf("continue?\n"); + scanf("%s",&e); + if(strcmp(e,"no")==0) + menuprint(); + else if(strcmp(e,"yes")==0) + input(); + +} +void delet()/*ɾ³ý³ÌÐò*/ +{ + int i,j; + int k;/*´¢´æ³¤¶È*/ + k=len; + char e[1001],f[1001]; + scanf("%s",&e); + if(len>1) + { + for(i=1;i<=len;i++) + { + if(strcmp(stu[i].id,e)==0||strcmp(stu[i].name,e)==0) + { + + k--; + for(j=i;j<=len;j++) + { + strcpy(stu[j].id, stu[j+1].id); + stu[j].clas=stu[j+1].clas; + strcpy(stu[j].name,stu[j+1].name); + stu[j].a=stu[j+1].a; + stu[j].b=stu[j+1].b; + stu[j].c=stu[j+1].c; + stu[j].d=stu[j+1].d; + } + } +} +if(k!=len) +len=k; +print(); +} +else if(len<=1) +printf("You can't delete this one because there is only one student in it!\n"); + printf("continue?\n"); +scanf("%s",&f); + if(strcmp(f,"no")==0) + menuprint(); + else if(strcmp(f,"yes")==0) + delet(); +} +void selecting() +{ + char e[1001],f[1001]; + scanf("%s",&e); + int i,j; + for(i=1;i<=len;i++) + { + if(strcmp(stu[i].id,e)==0||strcmp(stu[i].name,e)==0) + { + printf("%s,%d,%s,%.1lf,%.1lf,%.1lf,%.1lf\n",stu[i].id,stu[i].clas,stu[i].name,stu[i].a,stu[i].b,stu[i].c,stu[i].d); + } +} + printf("continue?\n"); +scanf("%s",&f); + if(strcmp(f,"no")==0) + menuprint(); + else if(strcmp(f,"yes")==0) + selecting(); +} +void sortclass()/*°à¼¶ÅÅÐò³ÌÐò*/ +{ + int i,j; + char e[1001]="0"; + int t=0; + double k=0; + for(i=1;i<=len;i++)/*ðÅÝ*/ + for(j=1;j<=len-i;j++) + { + if(stu[j].clas>stu[j+1].clas) + { + t=stu[j].clas; + stu[j].clas=stu[j+1].clas; + stu[j+1].clas=t; + strcpy(e,stu[j].id); + strcpy(stu[j].id, stu[j+1].id); + strcpy(stu[j+1].id,e); + strcpy(e,stu[j].name); + strcpy(stu[j].name, stu[j+1].name); + strcpy(stu[j+1].name,e); + k=stu[j].a; + stu[j].a=stu[j+1].a; + stu[j+1].a=k; + k=stu[j].b; + stu[j].b=stu[j+1].b; + stu[j+1].b=k; + k=stu[j].c; + stu[j].c=stu[j+1].c; + stu[j+1].c=k; + k=stu[j].d; + stu[j].d=stu[j+1].d; + stu[j+1].d=k; + } + } +} +void sortexam(int m,int h)/*°àÄÚÅÅÐò³ÌÐò*/ +{ + int i,j; + char e[1001]="0"; + int t=0; + double k=0; + for(i=m;i<=h;i++)/*ðÅÝ*/ + for(j=m;j<=h-i;j++) + { + if(stu[j].d