From f208414131b92bf5112a50659c645012f87b60f2 Mon Sep 17 00:00:00 2001 From: p56isruwj <3475735425@qq.com> Date: Mon, 13 Nov 2023 22:31:03 +0800 Subject: [PATCH] ADD file via upload --- 学籍管理系统步骤8.c | 170 ++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 学籍管理系统步骤8.c diff --git a/学籍管理系统步骤8.c b/学籍管理系统步骤8.c new file mode 100644 index 0000000..a481ed9 --- /dev/null +++ b/学籍管理系统步骤8.c @@ -0,0 +1,170 @@ +#include +#include +#include +int N=0; +void menu(); +struct stu_info +{ + int cls,flag; + char name[10],num[10]; + float maths,physics,english; +} +stu[20]; +void output() +{ + int i; + for(i=0;icls>(stu+j+1)->cls)||((stu+j)->cls==(stu+j+1)->cls)&&((stu+j)->num>(stu+j+1)->num)) + { + tmp = *(stu+j); + *(stu+j) = *(stu+j+1); + *(stu+j+1) = tmp; + } + } + } + return; +} +void input() +{ + int i; + char y[5]; + for(i=0;;i++) + { + printf("Id ");scanf("%s",stu[i].num); + printf("class ");scanf("%d",&stu[i].cls); + printf("name ");scanf("%s",stu[i].name); + printf("score1 ");scanf("%f",&stu[i].maths); + printf("score2 ");scanf("%f",&stu[i].physics); + printf("score3 ");scanf("%f",&stu[i].english); + printf("Continue?\n"); + again1: + scanf("%s",y); + if(strcmp(y,"yes")==0) continue; + else if(strcmp(y,"no")==0) + { + N=i+1; + menu(); + break; + } + else + { + printf("wrong input\n"); + goto again1; + } + } +} +void del(struct stu_info* stu) +{ + char key[10];char y[5]; + scanf("%s",key); + int i; + for (i=0;inum,key)==0||strcmp((stu+i)->name,key)==0) + { + N--; + for(int j=i;jnum,key)==0||strcmp((stu+i)->name,key)==0) + { + e=0; + printf("%s %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].maths,stu[i].physics,stu[i].english); + } + } + if(e) printf("there is no eligible student\n"); + printf("Continue?\n"); + again3: + scanf("%s",y); + if(strcmp(y,"yes")==0) sel(stu); + else if(strcmp(y,"no")==0) + { + menu(); + } + else + { + printf("wrong input\n"); + goto again3; + } +} +void order() +{ + sort(stu,N); + output(); + menu(); +} +void menu() +{ + int in; + 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"); + scanf("%d",&in); + switch(in) + { + case(1): + input(); + break; + case(2): + del(stu); + break; + case(3): + sel(stu); + break; + case(4): + order(); + break; + case(5): + output(); + menu(); + break; + case(6): + exit(0); + default: + printf("Wrong input\n"); + } +} +int main() +{ + menu(); + return 0; +}