├── demo.gif ├── StudentManageSystem ├── Debug │ ├── vc142.idb │ ├── vc142.pdb │ ├── StudentManageSystem.exe │ ├── StudentManageSystem.ilk │ ├── StudentManageSystem.obj │ ├── StudentManageSystem.pdb │ ├── StudentM.41E8BB15.tlog │ │ ├── CL.read.1.tlog │ │ ├── CL.write.1.tlog │ │ ├── CL.command.1.tlog │ │ ├── link.read.1.tlog │ │ ├── link.write.1.tlog │ │ ├── link.command.1.tlog │ │ └── StudentManageSystem.lastbuildstate │ └── StudentManageSystem.log ├── stuinfo.dat ├── StudentManageSystem.h ├── StudentManageSystem.cpp ├── appendix │ ├── 20190415_200358.mp4 │ ├── 20190415_200600.gif │ └── StudentManageSystem.md ├── .vs │ └── StudentManageSystem │ │ └── v16 │ │ ├── .suo │ │ ├── Browse.VC.db │ │ └── ipch │ │ └── AutoPCH │ │ ├── 215e20dca6177113 │ │ └── STUDENTMANAGESYSTEM.ipch │ │ └── a6730596ebf88ad0 │ │ └── STUDENTMANAGESYSTEM.ipch ├── StudentManageSystem.vcxproj.user ├── StudentManageSystem.vcxproj.filters ├── StudentManageSystem.sln └── StudentManageSystem.vcxproj ├── LICENSE └── README.md /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/demo.gif -------------------------------------------------------------------------------- /StudentManageSystem/Debug/vc142.idb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/vc142.idb -------------------------------------------------------------------------------- /StudentManageSystem/Debug/vc142.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/vc142.pdb -------------------------------------------------------------------------------- /StudentManageSystem/stuinfo.dat: -------------------------------------------------------------------------------- 1 | * 23 * b * v * 5 * 89 * 2 | * 6 * j * l * 8 * 2 * 3 | * 9 * d4 * 6 * 2 * 3 * 4 | * 56 * m * l * 8 * 2 * 5 | -------------------------------------------------------------------------------- /StudentManageSystem/StudentManageSystem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/StudentManageSystem.h -------------------------------------------------------------------------------- /StudentManageSystem/StudentManageSystem.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/StudentManageSystem.cpp -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentManageSystem.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentManageSystem.exe -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentManageSystem.ilk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentManageSystem.ilk -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentManageSystem.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentManageSystem.obj -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentManageSystem.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentManageSystem.pdb -------------------------------------------------------------------------------- /StudentManageSystem/appendix/20190415_200358.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/appendix/20190415_200358.mp4 -------------------------------------------------------------------------------- /StudentManageSystem/appendix/20190415_200600.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/appendix/20190415_200600.gif -------------------------------------------------------------------------------- /StudentManageSystem/.vs/StudentManageSystem/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/.vs/StudentManageSystem/v16/.suo -------------------------------------------------------------------------------- /StudentManageSystem/.vs/StudentManageSystem/v16/Browse.VC.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/.vs/StudentManageSystem/v16/Browse.VC.db -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentM.41E8BB15.tlog/CL.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentM.41E8BB15.tlog/CL.read.1.tlog -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentM.41E8BB15.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentM.41E8BB15.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentM.41E8BB15.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentM.41E8BB15.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentM.41E8BB15.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentM.41E8BB15.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentM.41E8BB15.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentM.41E8BB15.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentManageSystem.log: -------------------------------------------------------------------------------- 1 | StudentManageSystem.cpp 2 | StudentManageSystem.vcxproj -> H:\Codes\Visual Studio 2019\StudentManageSystem\Debug\StudentManageSystem.exe 3 | -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentM.41E8BB15.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/Debug/StudentM.41E8BB15.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /StudentManageSystem/StudentManageSystem.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /StudentManageSystem/.vs/StudentManageSystem/v16/ipch/AutoPCH/215e20dca6177113/STUDENTMANAGESYSTEM.ipch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/.vs/StudentManageSystem/v16/ipch/AutoPCH/215e20dca6177113/STUDENTMANAGESYSTEM.ipch -------------------------------------------------------------------------------- /StudentManageSystem/.vs/StudentManageSystem/v16/ipch/AutoPCH/a6730596ebf88ad0/STUDENTMANAGESYSTEM.ipch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz2summer/StudentManageSystem/HEAD/StudentManageSystem/.vs/StudentManageSystem/v16/ipch/AutoPCH/a6730596ebf88ad0/STUDENTMANAGESYSTEM.ipch -------------------------------------------------------------------------------- /StudentManageSystem/Debug/StudentM.41E8BB15.tlog/StudentManageSystem.lastbuildstate: -------------------------------------------------------------------------------- 1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0 2 | Debug|Win32|H:\Codes\Visual Studio 2019\StudentManageSystem\| 3 | -------------------------------------------------------------------------------- /StudentManageSystem/StudentManageSystem.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 23 | 24 | 头文件 25 | 26 | 27 | -------------------------------------------------------------------------------- /StudentManageSystem/StudentManageSystem.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28803.156 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StudentManageSystem", "StudentManageSystem.vcxproj", "{41E8BB15-4718-44FD-A339-2E9153C54471}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Debug|x64.ActiveCfg = Debug|x64 17 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Debug|x64.Build.0 = Debug|x64 18 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Debug|x86.ActiveCfg = Debug|Win32 19 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Debug|x86.Build.0 = Debug|Win32 20 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Release|x64.ActiveCfg = Release|x64 21 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Release|x64.Build.0 = Release|x64 22 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Release|x86.ActiveCfg = Release|Win32 23 | {41E8BB15-4718-44FD-A339-2E9153C54471}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {71090FCF-EF6B-4A46-ADD2-39B7C7B55213} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /StudentManageSystem/StudentManageSystem.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | {41E8BB15-4718-44FD-A339-2E9153C54471} 24 | StudentManageSystem 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v142 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v142 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v142 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v142 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | Disabled 77 | true 78 | true 79 | _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 80 | 81 | 82 | Console 83 | 84 | 85 | 86 | 87 | Level3 88 | Disabled 89 | true 90 | true 91 | 92 | 93 | Console 94 | 95 | 96 | 97 | 98 | Level3 99 | MaxSpeed 100 | true 101 | true 102 | true 103 | true 104 | 105 | 106 | Console 107 | true 108 | true 109 | 110 | 111 | 112 | 113 | Level3 114 | MaxSpeed 115 | true 116 | true 117 | true 118 | true 119 | 120 | 121 | Console 122 | true 123 | true 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /StudentManageSystem/appendix/StudentManageSystem.md: -------------------------------------------------------------------------------- 1 | 2 |

学生成绩管理系统

3 | 4 |
开发语言:C语言
5 | 6 |
开发工具:Visual Studio 2019
7 | 8 |
开发时间:2019.4.14
9 | 10 |
开发者:summer
11 | 12 | @[一、系统使用展示](#1) 13 | 14 | @[二、系统功能](#2) 15 | 16 | @[三、菜单](#3) 17 | 18 | @[四、录入学生信息](#4) 19 | 20 | @[五、打印学生信息](#5) 21 | 22 | @[六、保存学生信息](#6) 23 | 24 | @[七、读取学生信息](#7) 25 | 26 | @[八、统计所有学生人数](#8) 27 | 28 | @[九、查找学生信息](#9) 29 | 30 | @[十、修改学生信息](#10) 31 | 32 | @[十一、删除学生信息](#11) 33 | 34 | @[十二、退出系统](#12) 35 | 36 | @[十三、出错](#13) 37 | 38 | 39 |

一、系统使用展示

40 | 41 | 42 | ![Alt](https://img-blog.csdnimg.cn/20190415200736234.gif) 43 | 44 | 45 |

二、系统功能

46 | 47 | 1. 系统功能介绍 48 | 49 | ``` 50 | 1.录入学生信息:用户可以自由输入学生信息到系统中。 51 | 2.打印学生信息:格式化展示系统中的学生信息。 52 | 3.保存学生信息:将系统中的学生信息保存到本地文档。 53 | 4.读取学生信息:读取本地文档中的学生信息并显示。 54 | 5.统计所有学生人数 55 | 6.查找学生信息:根据用户给定的信息(学号)在系统中查找该学生的信息 56 | 7.修改学生信息 57 | 8.删除学生信息 58 | 0.退出系统 59 | ``` 60 | 61 | 62 | 2. 系统main函数,while循环在外,系统程序能够持续运行,switch判断语句进行功能选择与函数切换。 63 | 64 | ```C 65 | int main() { 66 | while (1) 67 | { 68 | //打印菜单 69 | Menu(); 70 | //读取一个字符 整数,字符在内存中映射为ASCII码 71 | char ch = _getch(); 72 | 73 | switch (ch) 74 | { 75 | case '1'://1.录入学生信息 76 | InputStudent(); 77 | break; 78 | case '2'://2.打印学生信息 79 | PrintStudent(); 80 | break; 81 | case '3'://3.保存学生信息 82 | SaveStudent(); 83 | break; 84 | case '4'://4.读取学生信息 85 | ReadStudent(); 86 | break; 87 | case '5'://5.统计所有学生人数 88 | CountStudent(); 89 | break; 90 | case '6'://6.查找学生信息 91 | FindStudent(); 92 | break; 93 | case '7'://7.修改学生信息 94 | ChangeStudent(); 95 | break; 96 | case '8'://8.删除学生信息 97 | DeleteStudent(); 98 | break; 99 | case '0'://0.退出系统 100 | return 0; 101 | break; 102 | default: 103 | printf("输入有误,没有该功能\n\n"); 104 | system("pause"); //暂停 105 | system("cls"); //清屏 106 | break; 107 | } 108 | } 109 | 110 | return 0; 111 | } 112 | ``` 113 | 114 |

三、菜单

115 | 116 | 1. 菜单显示 117 | 118 | ```C 119 | //菜单 120 | void Menu() { 121 | printf("*************************************************\n"); 122 | printf("*\t欢迎使用高校学生成绩管理系统V1.0\t*\n"); 123 | printf("*\t\t请选择功能\t\t\t*\n"); 124 | printf("*************************************************\n"); 125 | printf("*\t\t1.录入学生信息\t\t\t*\n"); 126 | printf("*\t\t2.打印学生信息\t\t\t*\n"); 127 | printf("*\t\t3.保存学生信息\t\t\t*\n"); 128 | printf("*\t\t4.读取学生信息\t\t\t*\n"); 129 | printf("*\t\t5.统计所有学生人数\t\t*\n"); 130 | printf("*\t\t6.查找学生信息\t\t\t*\n"); 131 | printf("*\t\t7.修改学生信息\t\t\t*\n"); 132 | printf("*\t\t8.删除学生信息\t\t\t*\n"); 133 | printf("*\t\t0.退出系统\t\t\t*\n"); 134 | printf("*************************************************\n"); 135 | } 136 | ``` 137 | 138 | 2. 打印菜单 139 | 140 | scanf()、getchar()输入后均需要按enter,而getch()不用 141 | 142 | ```C 143 | //打印菜单 144 | Menu(); 145 | //读取一个字符 整数,字符在内存中映射为ASCII码 146 | char ch = _getch(); 147 | ``` 148 | 149 | 150 |

四、录入学生信息

151 | 152 | 1. 定义学生结构体、链表节点结构体 153 | 154 | ```C 155 | //定义一个学生 156 | typedef struct tagStudent { 157 | char szName[20]; //姓名 158 | char szSex[4]; //性别 159 | int nAge; //年龄 160 | int nStuNo; //学号 161 | int nScore; //成绩 162 | }Student; 163 | 164 | //链表 165 | //节点 166 | typedef struct tagNode 167 | { 168 | Student stu; //学生信息 169 | struct tagNode* pNext; //指向下一个节点 170 | }Node; 171 | 172 | //创建头节点 173 | Node* g_pHead = NULL; //指向头节点 174 | ``` 175 | 176 | 177 | 2. 利用学生结构体,以及链表操作输入学生信息 178 | 179 | ```C 180 | //1.录入学生信息 181 | void InputStudent() { 182 | //创建一个人,在堆中分配内存 183 | Node* pNewNode = (Node*)malloc(sizeof(Node)); 184 | //指针下一个指向空 185 | pNewNode->pNext = NULL; 186 | 187 | //查找链表的尾结点 188 | Node* p = g_pHead; 189 | while (g_pHead != NULL && p->pNext != NULL) 190 | { 191 | p = p->pNext; 192 | } 193 | 194 | //把节点插到链表的尾节点 195 | if (g_pHead == NULL) { 196 | g_pHead = pNewNode; 197 | } 198 | else { 199 | p->pNext = pNewNode; 200 | } 201 | 202 | //录入学生信息 203 | printf("请输入学生姓名:\n"); 204 | scanf_s("%s", pNewNode->stu.szName, sizeof(pNewNode->stu.szName)); 205 | printf("请输入性别:\n"); 206 | scanf_s("%s", pNewNode->stu.szSex, sizeof(pNewNode->stu.szSex)); 207 | printf("请输入学生年龄:\n"); 208 | scanf_s("%d", &pNewNode->stu.nAge); 209 | printf("请输入学号:\n"); 210 | scanf_s("%d", &pNewNode->stu.nStuNo); 211 | printf("请输入成绩:\n"); 212 | scanf_s("%d", &pNewNode->stu.nScore); 213 | 214 | printf("学生信息录入成功。\n\n"); 215 | system("pause"); 216 | system("cls"); 217 | } 218 | ``` 219 | 220 |

五、打印学生信息

221 | 222 | 1. 读取链表结构,输出学生信息。先进行判空处理,如果无学生信息则输出提示信息,反之则正确输出学生信息。 223 | 224 | ```C 225 | //2.打印学生信息 226 | void PrintStudent() { 227 | 228 | system("cls"); 229 | //遍历链表 230 | Node* p = g_pHead; 231 | if (p == NULL) { 232 | printf("系统中暂无学生信息,请录入后再来打印查看。\n\n"); 233 | } 234 | else { 235 | printf("*********************************************************************************\n"); 236 | printf("*\t\t\t欢迎使用高校学生成绩管理系统V1.0\t\t\t*\n"); 237 | printf("*********************************************************************************\n"); 238 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 239 | printf("*********************************************************************************\n"); 240 | 241 | while (p != NULL) 242 | { 243 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 244 | p->stu.nStuNo, 245 | p->stu.szName, 246 | p->stu.szSex, 247 | p->stu.nAge, 248 | p->stu.nScore 249 | ); 250 | 251 | //下一个节点 252 | p = p->pNext; 253 | printf("*********************************************************************************\n"); 254 | } 255 | } 256 | 257 | system("pause"); 258 | system("cls"); 259 | } 260 | ``` 261 | 262 |

六、保存学生信息

263 | 264 | 1. 利用文件对学生信息进行存储 265 | 266 | ```C 267 | //3.保存学生信息 268 | void SaveStudent() { 269 | //打开文件 270 | FILE* pFile; 271 | pFile = fopen(".\\stuinfo.dat", "w"); 272 | 273 | if (pFile == NULL) { 274 | printf("打开文件失败。\n"); 275 | return; 276 | } 277 | 278 | //写入数据 279 | Node* p = g_pHead; 280 | while (p != NULL) 281 | { 282 | fwrite(&p->stu, sizeof(Node), 1, pFile); 283 | p = p->pNext; 284 | } 285 | 286 | //关闭文件 287 | fclose(pFile); 288 | 289 | printf("数据保存成功。\n"); 290 | system("pause"); 291 | system("cls"); 292 | } 293 | ``` 294 | 295 | 2. fopen在vs中会报错,解决方式 296 | 297 | (1)按照vs的提示,将fopen换成fopen_s 298 | 299 | (2)不修改函数,仅仅修改项目的属性。因为fopen_s是一种Microsoft的函数,若纯做Windows开发则直接改为_s也无妨,但是我们尽量还是用标准C++比较好,这样代码有较好的移植性。 300 | 301 | 具体操作: 302 | 303 | 右键工程名–>属性–>C/C++–>预处理器–>预处理器定义,编辑右边输入框加入: _CRT_SECURE_NO_WARNINGS 304 | 305 | 保存(注意用分号隔开)。 306 | 307 |

七、读取学生信息

308 | 309 | 1. 打开存储学生信息的文本,单个单词读取,判断非分隔符或者空时则赋值给链表中的节点,读取完毕后,直接调用PrintStudent()函数进行打印结果。 310 | 311 | ```C 312 | //4.读取学生信息 313 | void ReadStudent() { 314 | system("cls"); 315 | 316 | //打开文件 317 | FILE* pFile; 318 | pFile = fopen(".\\stuinfo.dat", "r"); 319 | 320 | if (pFile == NULL) { 321 | printf("打开文件失败。\n"); 322 | return; 323 | } 324 | 325 | //创建一个人,在堆中分配内存 326 | Node* p = (Node*)malloc(sizeof(Node)); 327 | p->pNext = NULL; 328 | //重新建立链表 329 | g_pHead = p; 330 | 331 | //逐个单词读入文本内容 332 | char str[200]; 333 | int i = 0; 334 | while (fscanf(pFile, "%s", str) != EOF) { //读文件 335 | //单词不是*或者空时,进行赋值 336 | if (strcmp(str, "*") && str != NULL) { 337 | switch (i) 338 | { 339 | case 0: 340 | p->stu.nStuNo = atoi(str); 341 | break; 342 | case 1: 343 | strcpy(p->stu.szName, str); 344 | break; 345 | case 2: 346 | strcpy(p->stu.szSex, str); 347 | break; 348 | case 3: 349 | p->stu.nAge = atoi(str); 350 | break; 351 | case 4: 352 | p->stu.nScore = atoi(str); 353 | break; 354 | default: 355 | Node* pNewNode = (Node*)malloc(sizeof(Node)); 356 | pNewNode->pNext = NULL; 357 | p->pNext = pNewNode; 358 | p = pNewNode; 359 | p->stu.nStuNo = atoi(str); 360 | i = 0; 361 | break; 362 | } 363 | i++; 364 | } 365 | } 366 | //打印读取结果 367 | PrintStudent(); 368 | } 369 | ``` 370 | 371 | 2. 读取文本时,将内容全部赋值给char数组,所有赋值时需特殊处理。 372 | 373 | - char数组赋值给整数 374 | 375 | 在头文件中有两个函数,int atoi(char *p)和char *itoa(int p),分别将装有整数的char数组转化为整数,和将整数按位数分解依次存入char数组中。 376 | 377 | - char数组赋值给char数组 378 | 379 | 用strcpy函数! 380 | 381 | 原型声明:extern char *strcpy(char *dest,char *src); 382 | 383 | 头文件:string.h 384 | 385 | 功能:把src所指由NULL结束的字符串复制到dest所指的数组中。 386 | 387 | 说明:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。 388 | 389 | 返回指向dest的指针。 390 | 391 | 注:不能使用memcpy(a, b, strlen(b)),会导致中文乱码。 392 | 393 | 394 |

八、统计所有学生人数

395 | 396 | 1. 设置计数器,遍历链表 397 | 398 | ```C 399 | //5.统计所有学生人数 400 | void CountStudent() { 401 | int countStu = 0; 402 | 403 | //遍历链表 404 | Node* p = g_pHead; 405 | while (p != NULL) 406 | { 407 | countStu++; 408 | p = p->pNext; 409 | } 410 | printf("学生总人数:%d\n\n", countStu); 411 | 412 | system("pause"); 413 | system("cls"); 414 | } 415 | ``` 416 | 417 |

九、查找学生信息

418 | 419 | 1. 本次查找以学号为示例,改用姓名等信息查询流程基本一致。 420 | 421 | 遍历链表,如果有符合信息的学生则打印,反之则继续下一个节点,若系统中无该学生信息,给予用户无结果提示。 422 | 423 | ```C 424 | //6.查找学生信息 425 | void FindStudent() { 426 | system("cls"); 427 | //以学号为查找示例,其他信息查找流程基本相似 428 | int stuNum; 429 | printf("请输入查找学生学号:"); 430 | scanf("%d", &stuNum); 431 | //遍历链表查找,查找到后进行信息显示 432 | Node* p = g_pHead; 433 | //对表头进行展示一次 434 | bool isShowHead = false; 435 | //记录是否有找到该学号的学生信息 436 | bool isFindStu = false; 437 | while (p != NULL) 438 | { 439 | if (stuNum == p->stu.nStuNo) { 440 | if (!isShowHead) { 441 | printf("*********************************************************************************\n"); 442 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 443 | printf("*********************************************************************************\n"); 444 | isShowHead = true; 445 | } 446 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 447 | p->stu.nStuNo, 448 | p->stu.szName, 449 | p->stu.szSex, 450 | p->stu.nAge, 451 | p->stu.nScore 452 | ); 453 | isFindStu = true; 454 | printf("*********************************************************************************\n"); 455 | } 456 | p = p->pNext; 457 | } 458 | 459 | if (!isFindStu) { 460 | printf("学号输入有误,系统中暂无该学生信息。\n\n"); 461 | } 462 | 463 | system("pause"); 464 | system("cls"); 465 | } 466 | ``` 467 | 468 |

十、修改学生信息

469 | 470 | 1. 可参考查找学生信息代码段,在查找后进行修改即可 471 | 472 | ```C 473 | //7.修改学生信息 474 | void ChangeStudent() { 475 | //以学号为查找示例,其他信息查找流程基本相似 476 | int stuNum; 477 | printf("请输入欲修改学生的学号:"); 478 | scanf("%d", &stuNum); 479 | //遍历链表查找,查找到后进行信息显示 480 | Node* p = g_pHead; 481 | //对表头进行展示一次 482 | bool isShowHead = false; 483 | //记录是否有找到该学号的学生信息 484 | bool isFindStu = false; 485 | while (p != NULL) 486 | { 487 | if (stuNum == p->stu.nStuNo) { 488 | if (!isShowHead) { 489 | printf("*********************************************************************************\n"); 490 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 491 | printf("*********************************************************************************\n"); 492 | isShowHead = true; 493 | } 494 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 495 | p->stu.nStuNo, 496 | p->stu.szName, 497 | p->stu.szSex, 498 | p->stu.nAge, 499 | p->stu.nScore 500 | ); 501 | //修改学生信息 502 | printf("请输入学生姓名:\n"); 503 | scanf_s("%s", p->stu.szName, sizeof(p->stu.szName)); 504 | printf("请输入性别:\n"); 505 | scanf_s("%s", p->stu.szSex, sizeof(p->stu.szSex)); 506 | printf("请输入学生年龄:\n"); 507 | scanf_s("%d", &p->stu.nAge); 508 | printf("请输入学号:\n"); 509 | scanf_s("%d", &p->stu.nStuNo); 510 | printf("请输入成绩:\n"); 511 | scanf_s("%d", &p->stu.nScore); 512 | isFindStu = true; 513 | printf("*********************************************************************************\n"); 514 | printf("学生信息修改成功,请注意及时保存。\n\n"); 515 | } 516 | p = p->pNext; 517 | } 518 | 519 | if (!isFindStu) { 520 | printf("学号输入有误,系统中暂无该学生信息,无法进行修改。\n\n"); 521 | } 522 | 523 | system("pause"); 524 | system("cls"); 525 | } 526 | ``` 527 | 528 |

十一、删除学生信息

529 | 530 | 1. 仍然以查找学生信息操作为基础,以学号为线索,查找到则进行删除,未查找到则进行错误提示,删除时需要区分当前节点是头结点、尾节点或者中间节点,不同节点操作不同,同时该删除仅作用于本次操作,需保存学生信息才能长久生效。 531 | 532 | ```C 533 | //8.删除学生信息 534 | void DeleteStudent() { 535 | system("cls"); 536 | //以学号为查找示例,其他信息查找流程基本相似 537 | int stuNum; 538 | printf("请输入删除学生的学号:"); 539 | scanf("%d", &stuNum); 540 | //遍历链表查找,查找到后进行信息显示 541 | Node* p = g_pHead; 542 | //记录前一个节点,删除时方便操作 543 | Node* beforeNode = g_pHead; 544 | 545 | //对表头进行展示一次 546 | bool isShowHead = false; 547 | //记录是否有找到该学号的学生信息 548 | bool isFindStu = false; 549 | while (p != NULL) 550 | { 551 | if (stuNum == p->stu.nStuNo) { 552 | if (!isShowHead) { 553 | printf("*********************************************************************************\n"); 554 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 555 | printf("*********************************************************************************\n"); 556 | isShowHead = true; 557 | } 558 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 559 | p->stu.nStuNo, 560 | p->stu.szName, 561 | p->stu.szSex, 562 | p->stu.nAge, 563 | p->stu.nScore 564 | ); 565 | isFindStu = true; 566 | printf("*********************************************************************************\n"); 567 | 568 | //删除节点为头节点 569 | if (p == g_pHead) { 570 | g_pHead = p->pNext; 571 | } 572 | //删除节点为尾节点 573 | else if (p->pNext == NULL) { 574 | p = beforeNode; 575 | p->pNext = NULL; 576 | } 577 | //删除节点为中间节点 578 | else { 579 | beforeNode->pNext = p->pNext; 580 | } 581 | printf("删除成功,请记得保存。\n\n"); 582 | } 583 | beforeNode = p; 584 | p = p->pNext; 585 | } 586 | 587 | if (!isFindStu) { 588 | printf("学号输入有误,系统中暂无该学生信息,无法进行删除操作。\n\n"); 589 | } 590 | 591 | system("pause"); 592 | system("cls"); 593 | } 594 | ``` 595 | 596 |

十二、退出系统

597 | 598 | 直接在选择0时,设置return即可。 599 | 600 | 601 |

十三、出错

602 | 603 | 用户输入有误时,进行提示信息输出即可。 604 | 605 | ```C 606 | printf("输入有误,没有该功能\n\n"); 607 | system("pause"); //暂停 608 | system("cls"); //清屏 609 | ``` 610 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

学生成绩管理系统

3 | 4 |
开发语言:C语言
5 | 6 |
开发工具:Visual Studio 2019
7 | 8 |
开发时间:2019.4.14
9 | 10 |
开发者:summer
11 | 12 | [一、系统使用展示](#1) 13 | 14 | [二、系统功能](#2) 15 | 16 | [三、菜单](#3) 17 | 18 | [四、录入学生信息](#4) 19 | 20 | [五、打印学生信息](#5) 21 | 22 | [六、保存学生信息](#6) 23 | 24 | [七、读取学生信息](#7) 25 | 26 | [八、统计所有学生人数](#8) 27 | 28 | [九、查找学生信息](#9) 29 | 30 | [十、修改学生信息](#10) 31 | 32 | [十一、删除学生信息](#11) 33 | 34 | [十二、退出系统](#12) 35 | 36 | [十三、出错](#13) 37 | 38 | 39 |

一、系统使用展示

40 | 41 | 42 | ![Alt](demo.gif) 43 | 44 | 45 |

二、系统功能

46 | 47 | 1. 系统功能介绍 48 | 49 | ``` 50 | 1.录入学生信息:用户可以自由输入学生信息到系统中。 51 | 2.打印学生信息:格式化展示系统中的学生信息。 52 | 3.保存学生信息:将系统中的学生信息保存到本地文档。 53 | 4.读取学生信息:读取本地文档中的学生信息并显示。 54 | 5.统计所有学生人数 55 | 6.查找学生信息:根据用户给定的信息(学号)在系统中查找该学生的信息 56 | 7.修改学生信息 57 | 8.删除学生信息 58 | 0.退出系统 59 | ``` 60 | 61 | 62 | 2. 系统main函数,while循环在外,系统程序能够持续运行,switch判断语句进行功能选择与函数切换。 63 | 64 | ```C 65 | int main() { 66 | while (1) 67 | { 68 | //打印菜单 69 | Menu(); 70 | //读取一个字符 整数,字符在内存中映射为ASCII码 71 | char ch = _getch(); 72 | 73 | switch (ch) 74 | { 75 | case '1'://1.录入学生信息 76 | InputStudent(); 77 | break; 78 | case '2'://2.打印学生信息 79 | PrintStudent(); 80 | break; 81 | case '3'://3.保存学生信息 82 | SaveStudent(); 83 | break; 84 | case '4'://4.读取学生信息 85 | ReadStudent(); 86 | break; 87 | case '5'://5.统计所有学生人数 88 | CountStudent(); 89 | break; 90 | case '6'://6.查找学生信息 91 | FindStudent(); 92 | break; 93 | case '7'://7.修改学生信息 94 | ChangeStudent(); 95 | break; 96 | case '8'://8.删除学生信息 97 | DeleteStudent(); 98 | break; 99 | case '0'://0.退出系统 100 | return 0; 101 | break; 102 | default: 103 | printf("输入有误,没有该功能\n\n"); 104 | system("pause"); //暂停 105 | system("cls"); //清屏 106 | break; 107 | } 108 | } 109 | 110 | return 0; 111 | } 112 | ``` 113 | 114 |

三、菜单

115 | 116 | 1. 菜单显示 117 | 118 | ```C 119 | //菜单 120 | void Menu() { 121 | printf("*************************************************\n"); 122 | printf("*\t欢迎使用高校学生成绩管理系统V1.0\t*\n"); 123 | printf("*\t\t请选择功能\t\t\t*\n"); 124 | printf("*************************************************\n"); 125 | printf("*\t\t1.录入学生信息\t\t\t*\n"); 126 | printf("*\t\t2.打印学生信息\t\t\t*\n"); 127 | printf("*\t\t3.保存学生信息\t\t\t*\n"); 128 | printf("*\t\t4.读取学生信息\t\t\t*\n"); 129 | printf("*\t\t5.统计所有学生人数\t\t*\n"); 130 | printf("*\t\t6.查找学生信息\t\t\t*\n"); 131 | printf("*\t\t7.修改学生信息\t\t\t*\n"); 132 | printf("*\t\t8.删除学生信息\t\t\t*\n"); 133 | printf("*\t\t0.退出系统\t\t\t*\n"); 134 | printf("*************************************************\n"); 135 | } 136 | ``` 137 | 138 | 2. 打印菜单 139 | 140 | scanf()、getchar()输入后均需要按enter,而getch()不用 141 | 142 | ```C 143 | //打印菜单 144 | Menu(); 145 | //读取一个字符 整数,字符在内存中映射为ASCII码 146 | char ch = _getch(); 147 | ``` 148 | 149 | 150 |

四、录入学生信息

151 | 152 | 1. 定义学生结构体、链表节点结构体 153 | 154 | ```C 155 | //定义一个学生 156 | typedef struct tagStudent { 157 | char szName[20]; //姓名 158 | char szSex[4]; //性别 159 | int nAge; //年龄 160 | int nStuNo; //学号 161 | int nScore; //成绩 162 | }Student; 163 | 164 | //链表 165 | //节点 166 | typedef struct tagNode 167 | { 168 | Student stu; //学生信息 169 | struct tagNode* pNext; //指向下一个节点 170 | }Node; 171 | 172 | //创建头节点 173 | Node* g_pHead = NULL; //指向头节点 174 | ``` 175 | 176 | 177 | 2. 利用学生结构体,以及链表操作输入学生信息 178 | 179 | ```C 180 | //1.录入学生信息 181 | void InputStudent() { 182 | //创建一个人,在堆中分配内存 183 | Node* pNewNode = (Node*)malloc(sizeof(Node)); 184 | //指针下一个指向空 185 | pNewNode->pNext = NULL; 186 | 187 | //查找链表的尾结点 188 | Node* p = g_pHead; 189 | while (g_pHead != NULL && p->pNext != NULL) 190 | { 191 | p = p->pNext; 192 | } 193 | 194 | //把节点插到链表的尾节点 195 | if (g_pHead == NULL) { 196 | g_pHead = pNewNode; 197 | } 198 | else { 199 | p->pNext = pNewNode; 200 | } 201 | 202 | //录入学生信息 203 | printf("请输入学生姓名:\n"); 204 | scanf_s("%s", pNewNode->stu.szName, sizeof(pNewNode->stu.szName)); 205 | printf("请输入性别:\n"); 206 | scanf_s("%s", pNewNode->stu.szSex, sizeof(pNewNode->stu.szSex)); 207 | printf("请输入学生年龄:\n"); 208 | scanf_s("%d", &pNewNode->stu.nAge); 209 | printf("请输入学号:\n"); 210 | scanf_s("%d", &pNewNode->stu.nStuNo); 211 | printf("请输入成绩:\n"); 212 | scanf_s("%d", &pNewNode->stu.nScore); 213 | 214 | printf("学生信息录入成功。\n\n"); 215 | system("pause"); 216 | system("cls"); 217 | } 218 | ``` 219 | 220 |

五、打印学生信息

221 | 222 | 1. 读取链表结构,输出学生信息。先进行判空处理,如果无学生信息则输出提示信息,反之则正确输出学生信息。 223 | 224 | ```C 225 | //2.打印学生信息 226 | void PrintStudent() { 227 | 228 | system("cls"); 229 | //遍历链表 230 | Node* p = g_pHead; 231 | if (p == NULL) { 232 | printf("系统中暂无学生信息,请录入后再来打印查看。\n\n"); 233 | } 234 | else { 235 | printf("*********************************************************************************\n"); 236 | printf("*\t\t\t欢迎使用高校学生成绩管理系统V1.0\t\t\t*\n"); 237 | printf("*********************************************************************************\n"); 238 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 239 | printf("*********************************************************************************\n"); 240 | 241 | while (p != NULL) 242 | { 243 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 244 | p->stu.nStuNo, 245 | p->stu.szName, 246 | p->stu.szSex, 247 | p->stu.nAge, 248 | p->stu.nScore 249 | ); 250 | 251 | //下一个节点 252 | p = p->pNext; 253 | printf("*********************************************************************************\n"); 254 | } 255 | } 256 | 257 | system("pause"); 258 | system("cls"); 259 | } 260 | ``` 261 | 262 |

六、保存学生信息

263 | 264 | 1. 利用文件对学生信息进行存储 265 | 266 | ```C 267 | //3.保存学生信息 268 | void SaveStudent() { 269 | //打开文件 270 | FILE* pFile; 271 | pFile = fopen(".\\stuinfo.dat", "w"); 272 | 273 | if (pFile == NULL) { 274 | printf("打开文件失败。\n"); 275 | return; 276 | } 277 | 278 | //写入数据 279 | Node* p = g_pHead; 280 | while (p != NULL) 281 | { 282 | fwrite(&p->stu, sizeof(Node), 1, pFile); 283 | p = p->pNext; 284 | } 285 | 286 | //关闭文件 287 | fclose(pFile); 288 | 289 | printf("数据保存成功。\n"); 290 | system("pause"); 291 | system("cls"); 292 | } 293 | ``` 294 | 295 | 2. fopen在vs中会报错,解决方式 296 | 297 | (1)按照vs的提示,将fopen换成fopen_s 298 | 299 | (2)不修改函数,仅仅修改项目的属性。因为fopen_s是一种Microsoft的函数,若纯做Windows开发则直接改为_s也无妨,但是我们尽量还是用标准C++比较好,这样代码有较好的移植性。 300 | 301 | 具体操作: 302 | 303 | 右键工程名–>属性–>C/C++–>预处理器–>预处理器定义,编辑右边输入框加入: _CRT_SECURE_NO_WARNINGS 304 | 305 | 保存(注意用分号隔开)。 306 | 307 |

七、读取学生信息

308 | 309 | 1. 打开存储学生信息的文本,单个单词读取,判断非分隔符或者空时则赋值给链表中的节点,读取完毕后,直接调用PrintStudent()函数进行打印结果。 310 | 311 | ```C 312 | //4.读取学生信息 313 | void ReadStudent() { 314 | system("cls"); 315 | 316 | //打开文件 317 | FILE* pFile; 318 | pFile = fopen(".\\stuinfo.dat", "r"); 319 | 320 | if (pFile == NULL) { 321 | printf("打开文件失败。\n"); 322 | return; 323 | } 324 | 325 | //创建一个人,在堆中分配内存 326 | Node* p = (Node*)malloc(sizeof(Node)); 327 | p->pNext = NULL; 328 | //重新建立链表 329 | g_pHead = p; 330 | 331 | //逐个单词读入文本内容 332 | char str[200]; 333 | int i = 0; 334 | while (fscanf(pFile, "%s", str) != EOF) { //读文件 335 | //单词不是*或者空时,进行赋值 336 | if (strcmp(str, "*") && str != NULL) { 337 | switch (i) 338 | { 339 | case 0: 340 | p->stu.nStuNo = atoi(str); 341 | break; 342 | case 1: 343 | strcpy(p->stu.szName, str); 344 | break; 345 | case 2: 346 | strcpy(p->stu.szSex, str); 347 | break; 348 | case 3: 349 | p->stu.nAge = atoi(str); 350 | break; 351 | case 4: 352 | p->stu.nScore = atoi(str); 353 | break; 354 | default: 355 | Node* pNewNode = (Node*)malloc(sizeof(Node)); 356 | pNewNode->pNext = NULL; 357 | p->pNext = pNewNode; 358 | p = pNewNode; 359 | p->stu.nStuNo = atoi(str); 360 | i = 0; 361 | break; 362 | } 363 | i++; 364 | } 365 | } 366 | //打印读取结果 367 | PrintStudent(); 368 | } 369 | ``` 370 | 371 | 2. 读取文本时,将内容全部赋值给char数组,所有赋值时需特殊处理。 372 | 373 | - char数组赋值给整数 374 | 375 | 在头文件中有两个函数,int atoi(char *p)和char *itoa(int p),分别将装有整数的char数组转化为整数,和将整数按位数分解依次存入char数组中。 376 | 377 | - char数组赋值给char数组 378 | 379 | 用strcpy函数! 380 | 381 | 原型声明:extern char *strcpy(char *dest,char *src); 382 | 383 | 头文件:string.h 384 | 385 | 功能:把src所指由NULL结束的字符串复制到dest所指的数组中。 386 | 387 | 说明:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。 388 | 389 | 返回指向dest的指针。 390 | 391 | 注:不能使用memcpy(a, b, strlen(b)),会导致中文乱码。 392 | 393 | 394 |

八、统计所有学生人数

395 | 396 | 1. 设置计数器,遍历链表 397 | 398 | ```C 399 | //5.统计所有学生人数 400 | void CountStudent() { 401 | int countStu = 0; 402 | 403 | //遍历链表 404 | Node* p = g_pHead; 405 | while (p != NULL) 406 | { 407 | countStu++; 408 | p = p->pNext; 409 | } 410 | printf("学生总人数:%d\n\n", countStu); 411 | 412 | system("pause"); 413 | system("cls"); 414 | } 415 | ``` 416 | 417 |

九、查找学生信息

418 | 419 | 1. 本次查找以学号为示例,改用姓名等信息查询流程基本一致。 420 | 421 | 遍历链表,如果有符合信息的学生则打印,反之则继续下一个节点,若系统中无该学生信息,给予用户无结果提示。 422 | 423 | ```C 424 | //6.查找学生信息 425 | void FindStudent() { 426 | system("cls"); 427 | //以学号为查找示例,其他信息查找流程基本相似 428 | int stuNum; 429 | printf("请输入查找学生学号:"); 430 | scanf("%d", &stuNum); 431 | //遍历链表查找,查找到后进行信息显示 432 | Node* p = g_pHead; 433 | //对表头进行展示一次 434 | bool isShowHead = false; 435 | //记录是否有找到该学号的学生信息 436 | bool isFindStu = false; 437 | while (p != NULL) 438 | { 439 | if (stuNum == p->stu.nStuNo) { 440 | if (!isShowHead) { 441 | printf("*********************************************************************************\n"); 442 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 443 | printf("*********************************************************************************\n"); 444 | isShowHead = true; 445 | } 446 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 447 | p->stu.nStuNo, 448 | p->stu.szName, 449 | p->stu.szSex, 450 | p->stu.nAge, 451 | p->stu.nScore 452 | ); 453 | isFindStu = true; 454 | printf("*********************************************************************************\n"); 455 | } 456 | p = p->pNext; 457 | } 458 | 459 | if (!isFindStu) { 460 | printf("学号输入有误,系统中暂无该学生信息。\n\n"); 461 | } 462 | 463 | system("pause"); 464 | system("cls"); 465 | } 466 | ``` 467 | 468 |

十、修改学生信息

469 | 470 | 1. 可参考查找学生信息代码段,在查找后进行修改即可 471 | 472 | ```C 473 | //7.修改学生信息 474 | void ChangeStudent() { 475 | //以学号为查找示例,其他信息查找流程基本相似 476 | int stuNum; 477 | printf("请输入欲修改学生的学号:"); 478 | scanf("%d", &stuNum); 479 | //遍历链表查找,查找到后进行信息显示 480 | Node* p = g_pHead; 481 | //对表头进行展示一次 482 | bool isShowHead = false; 483 | //记录是否有找到该学号的学生信息 484 | bool isFindStu = false; 485 | while (p != NULL) 486 | { 487 | if (stuNum == p->stu.nStuNo) { 488 | if (!isShowHead) { 489 | printf("*********************************************************************************\n"); 490 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 491 | printf("*********************************************************************************\n"); 492 | isShowHead = true; 493 | } 494 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 495 | p->stu.nStuNo, 496 | p->stu.szName, 497 | p->stu.szSex, 498 | p->stu.nAge, 499 | p->stu.nScore 500 | ); 501 | //修改学生信息 502 | printf("请输入学生姓名:\n"); 503 | scanf_s("%s", p->stu.szName, sizeof(p->stu.szName)); 504 | printf("请输入性别:\n"); 505 | scanf_s("%s", p->stu.szSex, sizeof(p->stu.szSex)); 506 | printf("请输入学生年龄:\n"); 507 | scanf_s("%d", &p->stu.nAge); 508 | printf("请输入学号:\n"); 509 | scanf_s("%d", &p->stu.nStuNo); 510 | printf("请输入成绩:\n"); 511 | scanf_s("%d", &p->stu.nScore); 512 | isFindStu = true; 513 | printf("*********************************************************************************\n"); 514 | printf("学生信息修改成功,请注意及时保存。\n\n"); 515 | } 516 | p = p->pNext; 517 | } 518 | 519 | if (!isFindStu) { 520 | printf("学号输入有误,系统中暂无该学生信息,无法进行修改。\n\n"); 521 | } 522 | 523 | system("pause"); 524 | system("cls"); 525 | } 526 | ``` 527 | 528 |

十一、删除学生信息

529 | 530 | 1. 仍然以查找学生信息操作为基础,以学号为线索,查找到则进行删除,未查找到则进行错误提示,删除时需要区分当前节点是头结点、尾节点或者中间节点,不同节点操作不同,同时该删除仅作用于本次操作,需保存学生信息才能长久生效。 531 | 532 | ```C 533 | //8.删除学生信息 534 | void DeleteStudent() { 535 | system("cls"); 536 | //以学号为查找示例,其他信息查找流程基本相似 537 | int stuNum; 538 | printf("请输入删除学生的学号:"); 539 | scanf("%d", &stuNum); 540 | //遍历链表查找,查找到后进行信息显示 541 | Node* p = g_pHead; 542 | //记录前一个节点,删除时方便操作 543 | Node* beforeNode = g_pHead; 544 | 545 | //对表头进行展示一次 546 | bool isShowHead = false; 547 | //记录是否有找到该学号的学生信息 548 | bool isFindStu = false; 549 | while (p != NULL) 550 | { 551 | if (stuNum == p->stu.nStuNo) { 552 | if (!isShowHead) { 553 | printf("*********************************************************************************\n"); 554 | printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n"); 555 | printf("*********************************************************************************\n"); 556 | isShowHead = true; 557 | } 558 | printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n", 559 | p->stu.nStuNo, 560 | p->stu.szName, 561 | p->stu.szSex, 562 | p->stu.nAge, 563 | p->stu.nScore 564 | ); 565 | isFindStu = true; 566 | printf("*********************************************************************************\n"); 567 | 568 | //删除节点为头节点 569 | if (p == g_pHead) { 570 | g_pHead = p->pNext; 571 | } 572 | //删除节点为尾节点 573 | else if (p->pNext == NULL) { 574 | p = beforeNode; 575 | p->pNext = NULL; 576 | } 577 | //删除节点为中间节点 578 | else { 579 | beforeNode->pNext = p->pNext; 580 | } 581 | printf("删除成功,请记得保存。\n\n"); 582 | } 583 | beforeNode = p; 584 | p = p->pNext; 585 | } 586 | 587 | if (!isFindStu) { 588 | printf("学号输入有误,系统中暂无该学生信息,无法进行删除操作。\n\n"); 589 | } 590 | 591 | system("pause"); 592 | system("cls"); 593 | } 594 | ``` 595 | 596 |

十二、退出系统

597 | 598 | 直接在选择0时,设置return即可。 599 | 600 | 601 |

十三、出错

602 | 603 | 用户输入有误时,进行提示信息输出即可。 604 | 605 | ```C 606 | printf("输入有误,没有该功能\n\n"); 607 | system("pause"); //暂停 608 | system("cls"); //清屏 609 | ``` 610 | *** 611 | 项目源码:[C语言开发简单的学生成绩管理系统](https://github.com/zz2summer/C-CPP-Programs/tree/master/C%E8%AF%AD%E8%A8%80%E5%BC%80%E5%8F%91%E7%AE%80%E5%8D%95%E7%9A%84%E5%AD%A6%E7%94%9F%E6%88%90%E7%BB%A9%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F) --------------------------------------------------------------------------------