From b4ee7cc3d96fbc15370b39c5bcee3bd3be4f64c1 Mon Sep 17 00:00:00 2001 From: zhouyufan <2467848647@qq.com> Date: Thu, 27 Apr 2023 21:17:37 +0800 Subject: [PATCH] zyf222 --- .gitignore | 54 -------- README.md | 382 ----------------------------------------------------- hello.md | 16 --- hello1.md | 18 --- hello2.md | 10 -- hello3.md | 13 -- readme1.md | 23 ---- 7 files changed, 516 deletions(-) delete mode 100644 .gitignore delete mode 100644 README.md delete mode 100644 hello.md delete mode 100644 hello1.md delete mode 100644 hello2.md delete mode 100644 hello3.md delete mode 100644 readme1.md diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cd531cf..0000000 --- a/.gitignore +++ /dev/null @@ -1,54 +0,0 @@ -# ---> C -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf - diff --git a/README.md b/README.md deleted file mode 100644 index c9499da..0000000 --- a/README.md +++ /dev/null @@ -1,382 +0,0 @@ -# System -#学生成绩管理系统代码 - -## 多个函数的使用 - -## 利用结构体 -下面是代码库 -````c - -#include -#include -#include -#define MAX_LEN 10 // 字符串最大长度 -#define STU_NUM 30 // 最多的学生人数 -#define COURSE_NUM 6 // 最多的考试科目数 -typedef struct student -{ - long num; // 每个学生的学号 - char name[MAX_LEN]; // 每个学生的姓名 - float score[COURSE_NUM]; // 每个学生COURSE_NUM门功课的成绩 - float sum; // 每个学生的总成绩 - float aver; // 每个学生的平均成绩 -}STU; -int Menu(void); -void ReadScore(STU stu[], int n, int m); -void AverSumofEveryStudent(STU stu[], int n, int m); -void AverSumofEveryCourse(STU stu[], int n, int m); -void SortbyScore(STU stu[],int n,int m,int (*compare)(float a,float b)); -int Ascending(float a, float b); -int Descending(float a, float b); -void SwapFloat(float *x, float *y); -void SwapLong(long *x, long *y); -void SwapChar(char x[], char y[]); -void AsSortbyNum(STU stu[], int n, int m); -void SortbyName(STU stu[], int n, int m); -void SearchbyNum(STU stu[], int n, int m); -void SearchbyName(STU stu[], int n, int m); -void StatisticAnalysis(STU stu[], int n, int m); -void PrintScore(STU stu[], int n, int m); -void WritetoFile(STU record[], int n, int m); -void ReadfromFile(STU record[], int *n, int *m); -int main(void) -{ - char ch; - int n = 0, m = 0; - STU stu[STU_NUM]; -printf("Input student number(n<%d):", STU_NUM); - scanf("%d", &n); -printf("Input course number(m<=%d):",COURSE_NUM); - scanf("%d", &m); - while (1) - { - ch = Menu(); // 显示菜单,并读取用户输入 - switch (ch) - { - case 1:ReadScore(stu, n, m); - break; - case 2: AverSumofEveryCourse(stu, n, m); - break; - case 3: AverSumofEveryStudent(stu, n, m); - break; - case 4: SortbyScore(stu, n, m, Descending); - printf("\nSort in descending order by score:\n"); - PrintScore(stu, n, m); - break; - case 5: SortbyScore(stu, n, m, Ascending); - printf("\nSort in ascending order by score:\n"); - PrintScore(stu, n, m); - break; - case 6: AsSortbyNum(stu, n, m); - printf("\nSort in ascending order by number:\n"); - PrintScore(stu, n, m); - break; - case 7: SortbyName(stu, n, m); - printf("\nSort in dictionary order by name:\n"); - PrintScore(stu, n, m); - break; - case 8: SearchbyNum(stu, n, m); - break; - case 9: SearchbyName(stu, n, m); - break; - case 10: StatisticAnalysis(stu, n, m); - break; - case 11:PrintScore(stu, n, m); - break; -case 12:WritetoFile(stu, n, m); - break; - case 13:ReadfromFile(stu, &n, &m); - break; - case 0: printf("End of program!"); - exit(0); - default:printf("Input error!"); - } - } - return 0;} -// 函数功能:显示菜单并获得用户键盘输入的选项 -int Menu(void) -{ - int itemSelected; - printf("Management for Students' scores\n"); - printf("1.Input record\n"); - printf("2.Calculate total and average score of every course\n"); - printf("3.Calculate total and average score of every student\n"); - printf("4.Sort in descending order by score\n"); - printf("5.Sort in ascending order by score\n"); - printf("6.Sort in ascending order by number\n"); - printf("7.Sort in dictionary order by name\n"); - printf("8.Search by number\n"); - printf("9.Search by name\n"); - printf("10.Statistic analysis\n"); - printf("11.List record\n"); - printf("12.Write to a file\n"); - printf("13.Read from a file\n"); - printf("0.Exit\n"); - printf("Please Input your choice:"); - scanf("%d", &itemSelected); // 读入用户输入 - return itemSelected; -} -// 函数功能:输入n个学生的m门课成绩 -void ReadScore(STU stu[], int n, int m) -{ - int i, j; - printf("Input student's ID, name and score:\n"); - /* ---------- begain ---------- */ - for(i=0;i0 ? stu[i].sum / m : -1; - printf("student %d: sum = %.0f, aver = %.0f\n", -i+1, stu[i].sum, stu[i].aver); - } -} -// 函数功能:计算每门课程的总分和平均分 -void AverSumofEveryCourse(STU stu[], int n, int m) -{ - int i, j; - float sum[COURSE_NUM], aver[COURSE_NUM]; - /* ---------- begain ---------- */ - for (j=0; j b; // 这样比较决定了按降序排序,如果a>b,则交换 -} -// 交换两个单精度浮点型数据 -void SwapFloat(float *x, float *y) -{ -float temp; -temp = *x; -*x = *y; -*y = temp; -} -// 交换两个长整型数据 -void SwapLong(long *x, long *y) -{ -long temp; -temp = *x; -*x = *y; -*y = temp; -} -// 交换两个字符串 -void SwapChar(char x[], char y[]) -{ -char temp[MAX_LEN]; -strcpy(temp, x); -strcpy(x, y); -strcpy(y, temp); -} -// 函数功能:按选择法将数组num的元素值按从低到高排序 -void AsSortbyNum(STU stu[], int n, int m) -{ - int i, j, k, t; - for (i=0; i=0 && stu[i].score[j]<60)t[0]++; - else if (stu[i].score[j]<70) t[1]++; - else if (stu[i].score[j]<80) t[2]++; - else if (stu[i].score[j]<90) t[3]++; - else if (stu[i].score[j]<100) t[4]++; - else if (stu[i].score[j] == 100) t[5]++; - } - for (i=0; i<=5; i++) - { - if (i==0) printf("<60\t%d\t%.2f%%\n",t[i],(float)t[i]/n*100); - else if (i==5) printf("%d\t%d\t%.2f%%\n", -(i+5)*10,t[i],(float)t[i]/n*100); - else printf("%d-%d\t%d\t%.2f%%\n", -(i+5)*10, (i+5)*10+9, t[i], (float)t[i]/n*100); - } - } -} -// 函数功能: 打印学生成绩 -void PrintScore(STU stu[], int n, int m) -{ - int i, j; - for (i=0; i