diff --git a/.drawio.svg b/.drawio.svg new file mode 100644 index 0000000..70038a5 --- /dev/null +++ b/.drawio.svg @@ -0,0 +1,153 @@ + + + + + + + + + +
+
+
+
+
+
+ + update_data + +
+
+
+
+
+
+
+
+
+
+
+
+ + update_data... + +
+
+ + + + + + + +
+
+
+ 输入学生学号 +
+
+
+
+ + 输入学生学号 + +
+
+ + + + + + + +
+
+
+ 查找学生是否已经能够录入 +
+
+
+
+ + 查找学生是否已经能够录入 + +
+
+ + + + +
+
+
+ 不存在 +
+
+
+
+ + 不存在 + +
+
+ + + + +
+
+
+ 存在 +
+
+
+
+ + 存在 + +
+
+ + + + +
+
+
+ 退出 +
+
+
+
+ + 退出 + +
+
+ + + + +
+
+
+ 输出学生信息 +
+
+
+
+ + 输出学生信息 + +
+
+
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..5472856 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "C:/mingw64/bin/gcc.exe", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "windows-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3a83391 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": "c:/Users/王德沅/c/test1", + "program": "c:/Users/王德沅/c/test1/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..65c81b6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,38 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wconversion", + "-Wnull-dereference", + "-Wsign-conversion" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false +} \ No newline at end of file diff --git a/README.md b/README.md index f62d5fe..10119f4 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ | ------ | ------ | ------ | ------ | | 25 | 25 | 25 | 25 | ->>>>>>> ec05cf9b65bc3b08589f06d0cbdf8236edde96dd + >>>>>>> >>>>>> >>>>> @@ -341,7 +341,7 @@ Step 2.4: if c == CMD_SAVE then 保存数据 Step 2.5: if c == CMD_PRINT then 打印数据 Step 2.6: -![主程序流程图](images/main.drawio.svg) +![picture-main.draw](/picture-main.drawio.svg) #### save_data @@ -351,7 +351,7 @@ Step 3: if 打开文件失败 then 提示打开文件失败并结束 Step 4: 将所有库存记录写入文件 Step 5: 关闭文件 -![保存数据流程图](images/save_data.drawio.svg) +![picture-save.draw](/picture-save.draw.svg) #### add_data @@ -362,7 +362,7 @@ Step 4: 输入零件名和库存数量 Step 5: 添加新零件到数据 Step 6: 提示添加成功 -![添加库存记录流程图](images/add_data.drawio.svg) +![picture-add.draw](/picture-add.drawio.svg) ### query_data @@ -372,7 +372,7 @@ Step 3:查询最后一个学生结束 Step 4:if未查询到提示学生不存在 Step 5:else打印学生信息 -![查询流程图](https://code.educoder.net/repo/p8rq79j4h/test1/raw/branch/master/picture.drawio.svg) +![picture.draw](/picture.drawio.svg) ### printf_data diff --git a/daima b/daima index 4d0fb6b..d437315 100644 --- a/daima +++ b/daima @@ -1,6 +1,6 @@ } -/ 函数定义 +// 函数定义 void init(void) { puts("程序启动"); diff --git a/daima1.c b/daima1.c new file mode 100644 index 0000000..96c5def --- /dev/null +++ b/daima1.c @@ -0,0 +1,90 @@ +#define NAME_LEN 31 +#define MAX_PARTS 100 +/保存学生成绩信息的结构 +struct students +{ + int number; + char name[NAME_LEN + 1]; + int score; +}; +static struct students stu[MAX_PARTS]; +static int num_parts = 0; +#include +#include + +//定义常量 +#define CMD_QUIT 0 +#define CMD_QUERY 4 +#define CMD_INSERT 5 +#define CMD_UPDATE 6 +#define CMD_DELETE 7 +#define CMD_READ 1 +#define CMD_SAVE 2 +#define CMD_PRINT 3 +#define CMD_SORT 8 +#define CMD_CHART 9 +// 菜单命令的编号 + +// 函数声明 +void init(void); +void quit(void); +void display_menu(void); +int make_choice(void); +void read_data(void); // 读取 +void save_data(void); // 保存 +void print_data(void); // 打印 +void query_data(void); // 查询 +void add_data(void); // 添加 +void update_data(void); // 修改 +void delete_data(void); // 删除 +void sort_data(void); // 排序 +void make_chart(void); // 图表 +int confirm(const char *msg); + +// 主程序 +int main(void) +{ + init(); // 程序启动 + while (1) + { + display_menu(); + int c = make_choice(); + switch (c) + { + case CMD_QUERY: + query_data(); + break; + case CMD_INSERT: + add_data(); + break; + case CMD_UPDATE: + update_data(); + break; + case CMD_DELETE: + delete_data(); + break; + case CMD_READ: + read_data(); + break; + case CMD_SAVE: + save_data(); + break; + case CMD_PRINT: + print_data(); + break; + case CMD_SORT: + sort_data(); + break; + case CMD_CHART: + make_chart(); + break; + default: + puts("命令错误,请重新选择"); + break; + case CMD_QUIT: + if (confirm("确定要退出吗?")) + quit(); // 仅在确认后退出 + break; + } + } + return 0; \ No newline at end of file diff --git a/delete.drawio.svg b/delete.drawio.svg new file mode 100644 index 0000000..51710f7 --- /dev/null +++ b/delete.drawio.svg @@ -0,0 +1,153 @@ + + + + + + + +
+
+
+ 输入学生学号 +
+
+
+
+ + 输入学生学号 + +
+
+ + + + + + +
+
+
+ 判断学号是否存在 +
+
+
+
+ + 判断学号是否存在 + +
+
+ + + + + + +
+
+
+ 删除 +
+
+
+
+ + 删除 + +
+
+ + + + + +
+
+
+ 提示不存在并结束 +
+
+
+
+ + 提示不存在并结束 + +
+
+ + + + +
+
+
+ 存在 +
+
+
+
+ + 存在 + +
+
+ + + + +
+
+
+ 不存在 +
+
+
+
+ + 不存在 + +
+
+ + + + + + +
+
+
+
+
+
+ + delete_data + +
+
+
+
+
+
+
+
+
+
+
+
+ + delete_data... + +
+
+ +
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file diff --git a/printf.drawio.svg b/printf.drawio.svg new file mode 100644 index 0000000..93e63b8 --- /dev/null +++ b/printf.drawio.svg @@ -0,0 +1,102 @@ + + + + + + + + + +
+
+
+
+
+
+ + printf_data + +
+
+
+
+
+
+
+
+
+
+
+
+ + printf_data... + +
+
+ + + + + + +
+
+
+ 打印学生学号和姓名 +
+
+
+
+ + 打印学生学号和姓名 + +
+
+ + + + + + +
+
+
+ for(i=0;i<n;i++) +
+ n为学生数 +
+
+
+
+ + for(i=0;i<n;i... + +
+
+ + + + +
+
+
+ 打印学生成绩 +
+
+
+
+ + 打印学生成绩 + +
+
+
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file diff --git a/query.drawio.svg b/query.drawio.svg new file mode 100644 index 0000000..56f5d2c --- /dev/null +++ b/query.drawio.svg @@ -0,0 +1,150 @@ + + + + + + + +
+
+
+
+

+ query_data +

+
+
+
+
+
+
+
+
+
+
+ + query_data... + +
+
+ + + + + +
+
+
+ for i=0 to num_parts +
+
+
+
+ + for i=0 to num_parts + +
+
+ + + + + + + +
+
+
+ 学生信息不存在 +
+
+
+
+ + 学生信息不存在 + +
+
+ + + + +
+
+
+ if 查询到 +
+
+
+
+ + if 查询到 + +
+
+ + + + +
+
+
+ else +
+
+
+
+ + else + +
+
+ + + + + +
+
+
+ 打印学生信息 +
+
+
+
+ + 打印学生信息 + +
+
+ + + + + +
+
+
+

+ 结束 +

+
+
+
+
+ + 结束 + +
+
+ +
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file diff --git a/sort.drawio.svg b/sort.drawio.svg new file mode 100644 index 0000000..953d35f --- /dev/null +++ b/sort.drawio.svg @@ -0,0 +1,230 @@ + + + + + + + + + +
+
+
+
+

+ sort_data +

+
+
+
+
+
+
+
+
+
+
+ + sort_data... + +
+
+ + + + + + +
+
+
+ 将学号按照从小到大排序 +
+
+
+
+ + 将学号按照从小到大排序 + +
+
+ + + + + + +
+
+
+ 将学生成绩进行比较 +
+
+
+
+ + 将学生成绩进行比较 + +
+
+ + + + + + + + +
+
+
+ 前者大于后者 +
+
+
+
+ + 前者大于后者 + +
+
+ + + + + + +
+
+
+ 顺序交换 +
+
+
+
+ + 顺序交换 + +
+
+ + + + + + +
+
+
+ 按照学号进行排序 +
+
+
+
+ + 按照学号进行排序 + +
+
+ + + + +
+
+
+ 成绩相同 +
+
+
+
+ + 成绩相同 + +
+
+ + + + + + + +
+
+
+ 不交换 +
+
+
+
+ + 不交换 + +
+
+ + + + + +
+
+
+ 前者小于后者 +
+
+
+
+ + 前者小于后者 + +
+
+ + + + + + +
+
+
+ 直至不在交换 +
+
+
+
+ + 直至不在交换 + +
+
+ + + + + +
+
+
+ 输出最终成绩排序 +
+
+
+
+ + 输出最终成绩排序 + +
+
+
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file