diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..8fe4bae --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc.exe 生成活动文件", + "command": "C:\\mingw64\\bin\\gcc.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "调试器生成的任务。" + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/学生成绩管理系统代码.c b/学生成绩管理系统代码.c new file mode 100644 index 0000000..5adfeda --- /dev/null +++ b/学生成绩管理系统代码.c @@ -0,0 +1,83 @@ +#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); +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: AverSumofEveryStudent(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("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); + } +} \ No newline at end of file