From f5ee6251c21c7235024b23a5362351538c7ca54d Mon Sep 17 00:00:00 2001 From: pngtmzsyq <864002285@qq.com> Date: Fri, 10 Nov 2023 11:21:38 +0800 Subject: [PATCH] ADD file via upload --- 作业2.8.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 作业2.8.c diff --git a/作业2.8.c b/作业2.8.c new file mode 100644 index 0000000..e88ed8c --- /dev/null +++ b/作业2.8.c @@ -0,0 +1,131 @@ +#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 id[10]; + scanf("%s",id); + int i; + 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