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/L.文件管理系统 b/L.文件管理系统 deleted file mode 100644 index 213cd3b..0000000 --- a/L.文件管理系统 +++ /dev/null @@ -1,10 +0,0 @@ -36.void AsSortbyNum(STU stu[], int n, int m) -37.{ -38. int i, j, k, t; -39. for (i=0; i b,则按降序排序。选择菜单命令 5 ,按选择法将数组 sum 的元素值按降序进行排序,显示提示信息,最后打印出学生成绩。 - -Please Input your choice: 4 -Sort in descending order by score: -2214111006 XuZilin 100 95 86 281 93 -2214111011 ZhangYu 85 91 98 274 91 -2214111009 XuZigui 77 89 99 265 88 -2214111025 LiYujia 75 89 100 264 88 -Please Input your choice: 5 -Sort in ascending order by score: -2214111025 LiYujia 75 89 100 264 88 -2214111009 XuZigui 77 89 99 265 88 -2214111011 ZhangYu 85 91 98 274 91 -2214111006 XuZilin 100 95 86 281 93 -C8: 学号顺序排序 -选择菜单命令 6 ,按学号从小到大进行排序,显示提示信息,最后打印学生信息。 - -Please Input your choice: 6 -Sort in ascending order by number: -2214111006 XuZilin 100 95 86 281 93 -2214111009 XuZigui 77 89 99 265 88 -2214111011 ZhangYu 85 91 98 274 91 -2214111025 LiYujia 75 89 100 264 88 -C9: 姓名顺序排序 -选择菜单命令 7 ,按姓名的字典顺序进行排序,显示提示信息,最后打印学生信息。 - -Please Input your choice: 7 -Sort in dictionary order by name: -2214111025 LiYujia 75 89 100 264 88 -2214111009 XuZigui 77 89 99 265 88 -2214111006 XuZilin 100 95 86 281 93 -2214111011 ZhangYu 85 91 98 274 91 -C10: 学生信息查询 -选择菜单命令 8 ,提示输入学生学号,若该学号存在,则输出学生信息;否则提示没有找到并结束。 -Please Input your choice: 8 -Input the number you want to search:2214111011 -2214111011 ZhangYu 85 91 98 274 91 -1 Input record -2 Calculate total and average score of every course -3 Calculate total and average score of every student -4 Sort in descending order by score -5 Sort in ascending order by score -6 Sort in ascending order by number -7 Sort in dictionary order by name -8 Search by number -9 Search by name -10 Statistic analysis -11 List record -12 Write to a file -13 Read from a file -0 Exit -Please Input your choice: 8 -Input the number you want to search:2214111001 -Not found! -选择菜单命令 9 ,提示输入学生姓名,若该姓名存在,则输出学生信息;否则提示没有找到并结束。 -Please Input your choice: 9 -Input the name you want to search:LiYujia -2214111025 LiYujia 75 89 100 264 88 -1 Input record -2 Calculate total and average score of every course -3 Calculate total and average score of every student -4 Sort in descending order by score -5 Sort in ascending order by score -6 Sort in ascending order by number -7 Sort in dictionary order by name -8 Search by number -9 Search by name -10 Statistic analysis -11 List record -12 Write to a file -13 Read from a file -0 Exit -Please Input your choice: 9 -Input the name you want to search:SunYizhe -Not found! -C11: 统计各分数段学生人数及所占百分比 -选择菜单命令 10,提示输入学生成绩,通过循环得出各分数段学生人数及所占百分比 - -Please Input your choice: 10 -For course 1: -<60 0 0.00% -60-70 0 0.00% -70-80 2 50.00% -80-90 1 25.00% -90-100 0 0.00% -100 1 25.00% -For course 2: -<60 0 0.00% -60-70 0 0.00% -70-80 0 00.00% -80-90 2 50.00% -90-100 2 50.00% -100 0 0.00% -For course 3: -<60 0 0.00% -60-70 0 0.00% -70-80 0 0.00% -80-90 1 25.00% -90-100 2 50.00% -100 1 25.00% -C12: 打印学生信息 -选择菜单命令11,打印 - -Please Input your choice: 11 -2214111006 XuZilin 100 95 86 281 93 -2214111009 XuZigui 77 89 99 265 88 -2214111011 ZhangYu 85 91 98 274 91 -2214111025 LiYujia 75 89 100 264 88 -C13: 将学生信息保存在文件中 -选择菜单命令 12 ,将学生信息保存在文件 student.txt 中。如果文件不存在,则给出错误信息并退出程序,否则逐个读入 - -Please Input your choice: 12 -Failure to open score.txt! -1 Input record -2 Calculate total and average score of every course -3 Calculate total and average score of every student -4 Sort in descending order by score -5 Sort in ascending order by score -6 Sort in ascending order by number -7 Sort in dictionary order by name -8 Search by number -9 Search by name -10 Statistic analysis -11 List record -12 Write to a file -13 Read from a file -0 Exit -Please Input your choice: 12 -2214111006 XuZilin 100 95 86 281 93 -2214111009 XuZigui 77 89 99 265 88 -2214111011 ZhangYu 85 91 98 274 91 -2214111025 LiYujia 75 89 100 264 88 -C14:从文件中读取学生信息 -选择菜单命令 13 ,从文件中读取学生的学号、姓名及成绩等信息写入到结构体数组 stu 中。如果文件为空,则给出错误信息并退出程序,反之,逐个读入 - -Please Input your choice: 13 -Failure to open score.txt! -1 Input record -2 Calculate total and average score of every course -3 Calculate total and average score of every student -4 Sort in descending order by score -5 Sort in ascending order by score -6 Sort in ascending order by number -7 Sort in dictionary order by name -8 Search by number -9 Search by name -10 Statistic analysis -11 List record -12 Write to a file -13 Read from a file -0 Exit -Please Input your choice: 13 -2214111006 XuZilin 100 95 86 281 93 -2214111009 XuZigui 77 89 99 265 88 -2214111011 ZhangYu 85 91 98 274 91 -2214111025 LiYujia 75 89 100 264 88 -概要设计 -系统主要分为用户界面和数据处理两大模块。 -用户界面模块包括系统初始化(init),显示菜单(display_menu),选择菜单命令(make_choice)、确认(confirm)、退出(quit)等子模块。 -数据处理模块包括读取数据(read_data)、保存数据(save_data)、打印数据(print_data)、查询数据(query_data)、添加数据(add_data)、更新数据(update_data)、删除数据(delete_data)、数据排序(sort_data)和生成图表(make_chart)等子模块。其中查询、添加、更 -新和删除数据还会用到根据编号查询数据的方法(find)。 - -上述各模块通过主程序(main)进行调用,系统模块图如下。 - -系统模块图 - -各模块的主要功能如下: - -main -系统主函数模块,显示菜单,根据用户选择的菜单命令,执行相关操作。 - -init -系统初始化 - -menu -显示菜单命令 - -详细设计 -针对概要设计 - -main -Step 1:初始化 -Step 2:根据用户选择的命令执行相应的操作 -Step 2.1:显示菜单 -Step 2.2:选择菜单命令 c -Step 2.3:if c == 1 then ReadScore -Step 2.4:if c == 2 then AverSumofEveryStudent -Step 2.5:if c == 3 then AverSumofEveryCourse -Step 2.6:if c == 4 then SortbyScore(Descending) -Step 2.7:if c == 5 then SortbyScore(Ascending) -Step 2.8:if c == 6 then AsSortbyNum -Step 2.9:if c == 7 then SortbyName -Step 2.10:if c == 8 then SearchbyNum -Step 2.11:if c == 9 then SearchbyName -Step 2.12:if c == 10 then StatisticAnalysis -Step 2.13:if c == 11 then PrintScore -Step 2.14:if c == 12 then WritetoFile -Step 2.15:if c == 13 then ReadfromFile -Step 2.16:if c == 0 then exit - -系统模块图 - -ReadScore -Step 1:显示提示信息,要求输入学生的学号,姓名和成绩 -Step 2:利用循环,输入学生的学号,成绩和各科成绩 - -学生信息输入 - -AverSumofEveryStudent -Step 1:利用for循环给 sum 赋初值为 0 -Step 2:利用第二重循环重新计算每个学生的总分 -Step 3:计算每个学生的平均分 -Step 4:将结果按照舒徐,总分和平均分的顺序进行输出 - -计算每个学生各门课程的总分和平均分 - -AverSumofEveryCourse -SortbyScore -SortbyScore -AsSortbyNum -SortbyName -SearchbyNum -SearchbyName -StatisticAnalysis -PrintScore -WritetoFile -ReadfromFile -exit -代码实现 -// 头文件的使用 - -#include -#include -#include -// define定义的全局变量 - -#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)); //选择法将数组 sum 的元素排序的函数 -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); //选择法将数组 num 的元素值从低到高排序的函数 -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); - scnaf("%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 number:\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("Are you sure you want to exit?(Y/N):"); - 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"); - 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]; - 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[],chary[]) -{ - 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 - - - - - - - - - \ No newline at end of file diff --git a/readme1.md b/readme1.md deleted file mode 100644 index e43585e..0000000 --- a/readme1.md +++ /dev/null @@ -1,395 +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; -} -//1 函数功能:输入n个学生的m门课成绩 -void ReadScore(STU stu[], int n, int m) -{ - int i, j; - printf("Input student's ID, name and score:\n"); - 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); - } -} -//3 函数功能:计算每门课程的总分和平均分 -void AverSumofEveryCourse(STU stu[], int n, int m) -{ - int i, j; - float sum[COURSE_NUM], aver[COURSE_NUM]; - for (j=0; j b; -} -// 7交换两个单精度浮点型数据 -void SwapFloat(float *x, float *y) -{ -float temp; -temp = *x; -*x = *y; -*y = temp; -} -// 8交换两个长整型数据 -void SwapLong(long *x, long *y) -{ -long temp; -temp = *x; -*x = *y; -*y = temp; -} -// 9交换两个字符串 -void SwapChar(char x[], char y[]) -{ -char temp[MAX_LEN]; -strcpy(temp, x); -strcpy(x, y); -strcpy(y, temp); -} -// 10函数功能:按选择法将数组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); - } - } -} - -// 15函数功能: 打印学生成绩 -void PrintScore(STU stu[], int n, int m) -{ - int i, j; - for (i=0; i - - - - - - - - - - -
-
-
- 开始 -
-
-
-
- - 开始 - -
-
- - - - - - -
-
-
- 输入 -
-
-
-
- - 输入 - -
-
- - - - - - -
-
-
- 输出 -
-
-
-
- - 输出 - -
-
- - - - -
-
-
- 结束 -
-
-
-
- - 结束 - -
-
-
- - - - - Text is not SVG - cannot display - - - - \ No newline at end of file diff --git a/test1.md b/test1.md deleted file mode 100644 index dd473af..0000000 --- a/test1.md +++ /dev/null @@ -1,11 +0,0 @@ -#### C1: 启动程序 - -输入n个学生的m门课成绩 -``` -库存管理系统启动 - -1 读取 | 2 保存 | 3 打印 | 4 查询 | 5 添加 -6 修改 | 7 删除 | 8 排序 | 9 图表 | 0 退出 - -请选择: -``` \ No newline at end of file diff --git a/按学号查找成绩 b/按学号查找成绩 deleted file mode 100644 index 3fdda08..0000000 --- a/按学号查找成绩 +++ /dev/null @@ -1,12 +0,0 @@ -//函数功能:按学号查找学生成绩并显示查找结果 -void SearchbyNum(STU stu[], int n, int m) -{ - long number; - int i, j; - printf("Input the number you want to search:) - scanf("%ld",&number); - - - - printf("\nNot found!\n"); -} \ No newline at end of file