From 6f464bd27570e130e55367bf9e2c5541ca131220 Mon Sep 17 00:00:00 2001 From: pvl836cjw <2745453479@qq.com> Date: Mon, 13 Nov 2023 20:34:03 +0800 Subject: [PATCH] ADD file via upload --- 步骤8.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 步骤8.c diff --git a/步骤8.c b/步骤8.c new file mode 100644 index 0000000..1153e98 --- /dev/null +++ b/步骤8.c @@ -0,0 +1,159 @@ +#include +#include +#include +typedef struct Student +{ + char *id; + int cl; + char *name; + float score1; + float score2; + float score3; + float total_score; +}Student; +void mainmenu() +{ + 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 inputStudentinfo(Student *students,int *size) +{ + printf("Id "); + students[*size].id=(char *)malloc(sizeof(char)*10); + scanf("%s",students[*size].id); + printf("class "); + scanf("%d",&students[*size].cl); + printf("name "); + students[*size].name=(char *)malloc(sizeof(char)*10); + scanf("%s",students[*size].name); + printf("score1 "); + scanf("%f",&students[*size].score1); + printf("score2 "); + scanf("%f",&students[*size].score2); + printf("score3 "); + scanf("%f",&students[*size].score3); + (*size)++; +} +void deleteinfo(Student* students, int* size) +{ + char id[10]; + scanf("%s",id); + int i; + for (i=0;i<*size;++i) { + if (strcmp(students[i].id,id) == 0) { + free(students[i].id); + free(students[i].name); + students[i]=students[--(*size)]; + return; + } + } +} +void select(Student* students,int size) +{ + char input[10]; + int i,index=0; + scanf("%s",input); + if(strlen(input)<=2){ + int cl=atoi(input); + for(i=0;istudents[j + 1].cl){ + Student temp=students[j]; + students[j]=students[j + 1]; + students[j + 1]=temp; + } + } + } +} +void output(Student* students,int size) +{ + int i; + for(i=0;i