2020年博客之星年度总评选:请为74号狗投票!
我的投票地址:点击为我投票
文章目录我的第二个博客,C++由于个人原因,NumberSum()没有写语言学生管理系统。。,这个程序最大的亮点不是你可以存储学生的数据,而是当你关闭程序并第二次打开它时,以前写的数据仍然存在,如果你需要写一个学生管理系统,这肯定会让你眼前一亮!话说回来,别人写的总是别人写的。如果你有幸看到我写的东西,我希望你能自己写!废话不多说,贴代码,下载源代码,需要的赶紧下载。
- 1.软件效果
- 2.显示软件介绍
- 3.①信息维护 ②信息检索 ③信息统计 ④退出系统
- 4.①建立学生成绩表 ②添加学生记录 ③删除学生记录 ④修改学生信息 ⑤查看记录的信息 ⑥返回上级菜单
- 5.①按姓名查找 ②按班级查找 ③返回上级菜单
- 6.①成绩统计 ②返回上级菜单
- 7.建立学生成绩表
- 8.添加学生记录
- 9.删除学生记录
- 10.修改学生信息
- 11.按班级搜索
- 12.按姓名搜索
- 13.成绩统计(空)
- 14.显示现有学生的信息
- 15.输出用户定制需要输出的内容
- 16.提供完整的代码,也可以自行下载。
void ShowP(){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);//红 cout << “学校学生信息管理系统(花狗制作) QQ/VX:2506897252 仅供学习使用)\n" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);//蓝 cout << “主要功能说明:” << endl; cout << 一、建立密码登录(模块a) << endl; cout << 以密码形式验证管理员身份(可输入三次),可以正确地进入密码,否则程序就结束了。" << endl; cout << “2.建立学生成绩表(模块b) << endl; cout << "建立新的学生成绩文件;" << endl; cout << “建立一些学生记录,包括姓名、学号、班级、课程、成绩,包括添加学生记录。" << endl; cout << 三、添加学生记录(模块c) << endl; cout << 在现有的学生成绩文件中添加新的记录。" << endl; cout << 4.删除学生记录(模块d) << endl; cout << “在学生成绩文件中删除三门课程不及格的学生记录;” << endl; cout << "删除前,逐一显示符合删除条件的学生姓名和成绩,确认后删除。" << endl; cout << 5.修改学生信息(模块e) << endl; cout << 输入学生学号,在学生成绩文件中找到学生记录;" << endl; cout << “学生的记录一个个显示在屏幕上;” << endl; cout << 如果“每次显示一个,询问是否修改,”Y输入修改后的数据," << endl; cout << 删除文件原记录,保存新记录;" << endl; cout << 6.根据姓名和班级搜索(模块f) << endl; cout << “输入姓名显示相应信息。" << endl; cout << 7.信息统计(模块g) << endl; cout << “同时,根据班级和课程统计每门课程和班级的平均成绩,最高分,最低分;" << endl; cout << “每门课程的统计数据首先依次显示在屏幕上,对应于每个班级。" << endl; cout << 退出信息管理系统,返回操作系统。" << endl; cout << “8.退出信息管理系统,返回操作系统。(模块h)” << endl;}
3.①信息维护 ②信息检索 ③信息统计 ④退出系统
int ListShow_1(){ cout << " ╔══════════════════════════════════╗\n"; cout << " ║══ ①信息维护 ══ ②信息检索 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ③信息统计 ══ ④退出系统 ══║\n"; cout << " ╚══════════════════════════════════╝\n"; MessageBoxA(NULL, “请选择功能”, “新闻(花狗制作)” MB_OK); int num_1; cin >> num_1; ///用户选择 system("cls"); return num_1;}
4.①建立学生成绩表 ②添加学生记录 ③删除学生记录 ④修改学生信息 ⑤查看记录的信息 ⑥返回上级菜单
int ListShow_2(){ cout << " ╔════════════════════════════════════════════╗\n"; cout << " ║══ ①建立学生成绩表 ══ ②添加学生记录 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ③删除学生记录 ══ ④修改学生信息 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ⑤查看记录的信息 ══ ⑥返回上级菜单 ══║\n"; cout << " ╚════════════════════════════════════════════╝\n"; MessageBoxA(NULL, “请再次选择功能(如果不是第一次使用,请不要选择1)” “新闻(花狗制作)” MB_OK); int num_2; cin >> num_2; ///用户选择 p = &num_2; system("cls"); return num_2;}
5.①按姓名查找 ②按班级查找 ③返回上级菜单
int ListShow_3(){ cout << " ╔══════════════════════════════════════╗\n"; cout << " ║══ ①按姓名查找 ══ ②按班级查找 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ③返回上级菜单 ║\n"; cout << " ╚══════════════════════════════════════╝\n"; MessageBoxA(NULL, “请再次选择功能”, “新闻(花狗制作)” MB_OK); int num_2; cin >> num_2; ///用户选择 p = &num_2; system("cls"); return num_2;}
6.①成绩统计 ②返回上级菜单
int ListShow_4(){ cout << " ╔══════════════════════════════════════╗\n"; cout << " ║══ ①成绩统计 ══ ②返回上级菜单 ══║\n"; cout << " ╚══════════════════════════════════════╝\n"; MessageBoxA(NULL, “请再次选择功能”, “新闻(花狗制作)” MB_OK); int num_2; cin >> num_2; ///用户选择 p = &num_2; system("cls"); return num_2;}
7.建立学生成绩表
void FoundStudent(char *File_system){ char File_[100]; //自定义文件地址 char Name_[20]; ///文件名称 int number[9] = { 31,31,31,31,31,31,31,31 };///科目选择 int sum = 0; //科目数 cout << 请输入文件保存地址(例如) D:我的软件\学生管理系统 地址中不存在空间”; cin >> File_; if (_access(File_, 00) == 0) { MessageBoxA(NULL, 指定地址成功!", “欢迎使用”, MB_OK); } else { MessageBoxA(NULL, “输入路径不存在,为您创建路径!接下来,请输入文件名(文件名后缀请写为.ini)", “欢迎使用”, MB_OK); _mkdir(File_);///如果路径中没有指定的文件夹,则创建文件夹 } cout << “请输入文件名:”; cin >> Name_; strcat(File_, "\\"); strcat(File_, Name_);///将文件名复制到路径后面 system("cls"); cout << " ╔══════════════════════╗\n"; cout << " ║══①语文══②数学══③英语══④政治══║\n"; cout << " ║ ║\n"; cout << " ║══⑤历史══⑥地理══⑦生物══⑧物理══║\n"; cout << " ║ ║\n"; cout << " ║══⑨化学 ║\n"; cout << " ╚══════════════════════╝\n"; MessageBoxA(NULL, “选择科目(选择一次回车\n至少选择三个科目\n,如果不选择,请输入0) “欢迎使用”, MB_OK); ofstream fout_1(File_);//默认调用方法 ofstream显式 fout.open(File_); fout_1.close(); ofstream fout(File_system); fout << "[FILE]" << endl;///分配文件地址和名称 fout << "地址=" << File_ << endl; fout << "[SUBGECT]" << endl;//分配科目 for (int i = 0; i < 9; i++) { cin >> number[i]; if (number[i] != 0)sum += 1; if (number[i] == 0) { number[i] = 31; break; } } for (int i = 0; i < 9; i++) { fout << “科目代码” << i + 1 << "=" << number[i] << endl; } fout << “科目总数=” << sum << endl; fout << ""[记录人数]" << endl; fout << "total=0" << endl; fout << “[是否第一次打开]” << endl; fout << "Frist=1" << endl; fout << “[是否第一次记录]” << endl; fout << "F=0" << endl; fout.close(); cout << “学生成绩表已经建立” << endl; cout << “立即添加学生信息(1), 返回上一级菜单(0) << endl; int CinJ = 0; cin >> CinJ; if (CinJ == 1) { system("cls"); AddStudent(File_system); } ///当程序正常运行时 代表返回上一层}
8.添加学生记录
void AddStudent(char * File_system){ char * Studata = NULL; Studata = new char[20];//信息 char * NUM_1 = NULL; NUM_1 = new char[100]; char File_[100]; //阅读文件地址 int ReturnSu = 0; ///阅读科目数 int total; //////阅读记录的总人数 char * total_f = NULL; total_f = new char[1000]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); ReturnSu = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); int number[9];///存储File_system配置文件中存储的科目 for (int i = 0; i < 9; i++) ////为number提供数据 { char Name[30] = “科目代码”; if (i == 0) { char NUM[3] = "1"; strcat(Name, NUM); } if (i == 1) { char NUM[3] = "2"; strcat(Name, NUM); } if (i == 2) { char NUM[3] = "3"; strcat(Name, NUM); } if (i == 3) { char NUM[3] = "4"; strcat(Name, NUM); } if (i == 4) { char NUM[3] = "5"; strcat(Name, NUM); } if (i == 5) { char NUM[3] = "6"; strcat(Name, NUM); } if (i == 6) { char NUM[3] = "7"; strcat(Name, NUM); } if (i == 7) { char NUM[3] = "8"; strcat(Name, NUM); } if (i == 8) { char NUM[3] = "9"; strcat(Name, NUM); } char *stu_ = Name; number[i] = GetPrivateProfileIntA("SUBGECT", stu_, -1, File_system); } cout << “已经选好了科目,请按以下格式记录学生信息:n"; SubjectJudge(number); ///显示需要输入的内容 MessageBoxA(NULL, “请严格按照上述信息顺序输入\n输入学生信息,然后按回车\n输入信息。请用空格将\n分开。如果您不输入下一个学生信息,请输入\"T\"结束", "提示", MB_OK); ofstream fout(File_, ios::ate | ios::app); ///阅读文件 for (int j = total + 1; j <= 1000; j++) { sprintf(NUM_1, "%d", j); if (strcmp(Studata, "T") == 0) { break; } for (int i = 1; i <= ReturnSu + 3; i++) { cin >> Studata; if (i == 1) { if (strcmp(Studata, "T") == 0) //如果输入T,则退出 { break; } WritePrivateProfileStringA(NUM_1, "姓名", Studata, File_); total += 1; sprintf(total_f, "%d", total); //int 转 字符串 WritePrivateProfileStringA(记录人数”, "total", total_f, File_system); } if (i == 2) { WritePrivateProfileStringA(NUM_1, "学号", Studata, File_); } if (i == 3) { WritePrivateProfileStringA(NUM_1, "班级", Studata, File_); } if (i == 4) { WritePrivateProfileStringA(NUM_1, "语文", Studata, File_); } if (i == 5) { WritePrivateProfileStringA(NUM_1, "数学", Studata, File_); } if (i == 6) { WritePrivateProfileStringA(NUM_1, "英语", Studata, File_); } if (i == 7) { WritePrivateProfileStringA(NUM_1, "政治", Studata, File_); } if (i == 8) { WritePrivateProfileStringA(NUM_1, "历史", Studata, File_); } if (i == 9) { WritePrivateProfileStringA(NUM_1, "地理", Studata, File_); } if (i == 10) { WritePrivateProfileStringA(NUM_1, "生物", Studata, File_); } if (i == 11) { WritePrivateProfileStringA(NUM_1, "物理", Studata, File_); } if (i == 12) { WritePrivateProfileStringA(NUM_1, "化学", Studata, File_); } WritePrivateProfileStringA(”是否第一次记录, "F", "1", File_system); } } fout.close(); ///关闭文件 delete[]Studata; delete[]NUM_1; delete[]total_f; cout << “信息已录入” << endl; cout << “返回上一级菜单(任意键) << endl; int e; cin >> e;}
9.删除学生记录
void DeleteStudent(char * File_system){ char File_[100]; //阅读文件地址 int total; //////阅读记录的总人数 int N; //获取科目数 int F; //获取记录 char CH[10]; /////获得的字符类型 int IN_; //获取的数字类型 int * percase = NULL; //记录删除标号 percase = new int[sizeof(int) * 100]; int persum = 0; //记录删除人数 char * SuIT = NULL; SuIT = new char[20]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); F = GetPrivateProfileIntA(”是否第一次记录, "F", -1, File_system); if (F == -1)MessageBoxA(NULL, “你没有记录任何学生信息,不能删除”, "消息", MB_OK); if (F == 0) MessageBoxA(NULL, “你没有记录任何学生信息,不能删除”, "消息", MB_OK); if (F == 1) { for (int j = 1; j <= total; j++) { int sum = 0; ///不合格科目 char Delename[50] = ""; for (int i = 1; i <= N + 3; i++) { char CH_F[10];///数字转字符 sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "未知", CH, sizeof(CH), File_); strcat(Delename, CH); strcat(Delename, " "); } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60) sum += 1; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } } if (sum >= 3) ///如果不及格的科目超过三门,打印同学的信息 { cout << Delename; cout << endl; percase[persum] = j;//012 persum += 1;///删除人数 //123 //出现bug } } } if (IDYES == MessageBoxA(NULL, 是否删除\\n 按 \"确认删除", “新闻(花狗制作)” MB_YESNO)) { for (int j = 1; j <= persum; j++) { char LS[10]; sprintf(LS, "%d", percase[j - 1]); WritePrivateProfileStringA(LS, NULL, NULL, File_); } } else { cout << “您已取消删除..."; } delete[]percase; delete[]SuIT; cout << “信息已处理完毕(任意键返回菜单)” << endl; int e; cin >> e;}
10.修改学生信息
void ChooesStudent(char * File_system){ int Stunumer = 0; //获得的学生学号 char File_[100]; //阅读文件地址 char CH[10]; /////获得的字符类型 int IN_; //获取的数字类型 char CH_[20]; int total; //////阅读记录的总人数 int N; //获取科目数 char * SuIT = NULL; SuIT = new char[20]; int a = 0; //当找到信息时,如果没有学号信息,a为0,提示输入错误是否再次输入 char CH_1[20]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); cout << 输入学号修改学生信息n"; cin >> Stunumer; for (int j = 1; j <= total; j++) { sprintf(CH_1, "%d", j); a = GetPrivateProfileIntA(CH_1, "学号", -1, File_); if (Stunumer == a) { for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); cout << "姓名:"; cout << CH << endl; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); cout << "学号:"; cout << IN_ << endl; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); cout << "班级:"; cout << IN_ << endl; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改语文成绩\n? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "语文", CH_, File_); } } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); if (IDYES == MessageBoxA(NULL, 数学成绩是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "数学", CH_, File_); } } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); if (IDYES == MessageBoxA(NULL, 英语成绩是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "英语", CH_, File_); } } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改政治成果\n? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "政治", CH_, File_); } } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改历史成就\n \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "历史", CH_, File_); } } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); if (IDYES == MessageBoxA(NULL, 地理成绩是否被修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "地理", CH_, File_); } } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改生物成分\n? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "生物", CH_, File_); } } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); if (IDYES == MessageBoxA(NULL, 物理成绩\n是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "物理", CH_, File_); } } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); if (IDYES == MessageBoxA(NULL, 化学成绩是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "化学", CH_, File_); } } } ++a; } } delete[]SuIT; cout << “信息已修改(任意键返回菜单)” << endl; int e; cin >> e;}
11.按班级搜索
void ClassSeatch(char * File_system){ int Stunumer = 0; //获得的学生班 char File_[100]; //阅读文件地址 char CH[10]; /////获得的字符类型 char CH_1[20]; int IN_; //获取的数字类型 int total; //////阅读记录的总人数 int N = 0; //获取科目数 char * SuIT = NULL; SuIT = new char[20]; int a = 0; //当找到信息时,如果没有学号信息,a为0,提示输入错误是否再次输入 int b = 0; //检查是否找到 GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); cout << 输入学生班级查看学生信息n"; while (1) { cin >> Stunumer; //获得班级 for (int j = 1; j <= total; j++) { sprintf(CH_1, "%d", j); a = GetPrivateProfileIntA(CH_1, "班级", -1, File_); if (Stunumer == a) { for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); cout << "姓名:"; cout << CH << endl; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); cout << "学号:"; cout << IN_ << endl; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); cout << "班级:"; cout << IN_ << endl; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); cout << "语文:"; cout << IN_ << endl; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); cout << "数学:"; cout << IN_ << endl; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); cout << "英语:"; cout << IN_ << endl; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); cout << "政治:"; cout << IN_ << endl; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); cout << "历史:"; cout << IN_ << endl; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); cout << "地理:"; cout << IN_ << endl; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); cout << "生物:"; cout << IN_ << endl; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); cout << "物理:"; cout << IN_ << endl; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); cout << "化学:"; cout << IN_ << endl; } } b = 1; } } if (b == 0) { cout << “你输入的班级错了,或者没有人在这个班” << endl; cout << “如果是按名字搜索,请按1,继续按班级搜索,请按2,任意键返回上级菜单” << endl; int w; cin >> w; if (w == 1) { NameSeatch(File_system); } if (w == 2) { } if (w != 1 && w != 1 && w != 2) { cout << "tuichu"; break; } } } delete[]SuIT;}
12.按姓名搜索
void NameSeatch(char * File_system){ char Stunumer[10]; //获得的学生姓名 char File_[100]; //阅读文件地址 char CH[10]; /////获得的字符类型 char CH_[20]; char CH_1[20]; int IN_; //获取的数字类型 int total; //////阅读记录的总人数 int N; //获取科目数 char * SuIT = NULL; SuIT = new char[20]; int a = 0; //当找到信息时,如果没有学号信息,a为0,提示输入错误是否再次输入 int b = 0; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); cout << 输入学生姓名查看学生信息n"; while (1) { cin >> Stunumer; b = 0; for (int j = 1; j <= total; j++) { sprintf(CH_1, "%d", j); GetPrivateProfileStringA(CH_1, "姓名", "未知", CH_, sizeof(CH_), File_); if (strcmp(Stunumer, CH_) == 0) { for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); cout << "姓名:"; cout << CH << endl; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); cout << "学号:"; cout << IN_ << endl; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); cout << "班级:"; cout << IN_ << endl; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); cout << "语文:"; cout << IN_ << endl; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); cout << "数学:"; cout << IN_ << endl; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); cout << "英语:"; cout << IN_ << endl; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); cout << "政治:"; cout << IN_ << endl; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); cout << "历史:"; cout << IN_ << endl; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); cout << "地理:"; cout << IN_ << endl; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); cout << "生物:"; cout << IN_ << endl; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); cout << "物理:"; cout << IN_ << endl; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); cout << "化学:"; cout << IN_ << endl; } } b = 1; } } if (b == 0) { cout << “你输入的名字是错误的,或者没有学生” << endl; cout << “如果是按班级搜索,请按1,继续按姓名搜索,请按2,任“意键返回上级菜单” << endl; int w; cin >> w; if (w == 1) { ClassSeatch(File_system); } if (w == 2) { } if (w != 1 && w != 2) { cout << "tuichu"; break; } } } delete[]SuIT;}
13.成绩统计(空)14.显示现有学生的信息
void ShowNew(char * File_system){ char File_[100]; //阅读文件地址 int total; //////阅读记录的总人数 int N; //获取科目数 int F; //获取记录 char CH[10]; /////获得的字符类型 int IN_; //获取的数字类型 char * SuIT = NULL; SuIT = new char[20]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); F = GetPrivateProfileIntA(”是否第一次记录, "F", -1, File_system); if (F == -1)MessageBoxA(NULL, “你没有记录任何学生信息”, "消息", MB_OK); if (F == 0) MessageBoxA(NULL, “你没有记录任何学生信息”, "消息", MB_OK); if (F == 1) { for (int j = 1; j <= total; j++) { int a = 0; for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); if (strcmp(CH, "error") != 0)cout << CH << " "; else ++a; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); if (IN_ != -1)cout << IN_ << " "; } } if (a == 0)cout << endl; } } delete[]SuIT; cout << “信息已查阅(任意键返回菜单)” << endl; int e; cin >> e;}
15.输出用户定制需要输出的内容
void SubjectJudge(int * number){ cout << "姓名 学号 班级 "; for (int i = 0; i < 9; i++) { if (*(number + i) == 1)cout << "语文 "; if (*(number + i) == 2)cout << "数学 "; if (*(number + i) == 3)cout << "英语 "; if (*(number + i) == 4)cout << "政治 "; if (*(number + i) == 5)cout << "历史 "; if (*(number + i) == 6)cout << "地理 "; if (*(number + i) == 7)cout << "生物 "; if (*(number + i) == 8)cout << "物理 "; if (*(number + i) == 9)cout << "化学 "; } cout << endl;}
16.提供完整的代码,也可以自行下载。
/************************************************* 2019.11.07 花狗 学生管理系统 vs2015 *************************************************/#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<fstream>#include<Windows.h>#include<io.h>#include<direct.h>#include<string>int * p = NULL; //指向ListShow_1()中的num_2char File_system[] = "C:\\Users\\FdogMain\\Desktop\\sms.ini";//系统初始化配置文件(包括用户创建的文件地址,自定义科目等。) 如果你没有,//我的桌面地址是这样的,请修改void ShowP(); ///显示软件介绍int介绍 ListShow_1(); //①信息维护 ②信息检索 ③信息统计 ④int退出系统 ListShow_2(); //①建立学生成绩表 ②添加学生记录 ③删除学生记录 ④修改学生信息 ⑤查看记录的信息 ⑥回到上级菜单int ListShow_3(); //①按姓名查找 ②按班级查找 ③回到上级菜单int ListShow_4(); //①成绩统计 ②回到上级菜单voidid FoundStudent(char *File_system); ///建立学生成绩表void AddStudent(char * File_system); ///添加学生记录 void DeleteStudent(char * File_system); ///删除学生记录 void ChooesStudent(char * File_system); ///修改学生信息 void ClassSeatch(char * File_system); ///按班级搜索 void NameSeatch(char * File_system); //按姓名搜索 void NumberSum(char * File_system); ///成绩统计 void ShowNew(char * File_system); ////显示现有学生的信息void SubjectJudge(int * number); ////输出用户定制需要输出的内容using namespace std;int main(){ const string password = "huagou"; ///初始设置密码 string password_2; //输入密码 if (IDYES == MessageBoxA(NULL, “请输入密码进入系统,如果忘记,请联系作者QQ2506897252\n(输入机会只有三次), "提示", MB_YESNO)); ///函数MessageBoxa将返回一个值,如果等于IDYES执行,否则退出 else exit(0); for (int I_F = 3; I_F >= 1; I_F--) { getline(cin, password_2); //getline是处理string类的函数; system("cls"); if (password == password_2) { MessageBoxA(NULL, “正确的密码”, "提示", MB_OK); break; } else if (I_F == 1 && IDOK == MessageBoxA(NULL, “密码错误”, "提示", MB_OK)) { cout << "次数已耗尽,已退出系统“退出系统”; system("pause>nul"); exit(0); }////最后一次是错误的 直接退出 else { MessageBoxA(NULL, “密码错误”, "提示", MB_OK); } } if (-1 == GetPrivateProfileIntA(“是否第一次打开”, "Frist", -1, "C:\\Users\\FdogMain\\Desktop\\sms.ini")) { ShowP(); MessageBoxA(NULL, “你好,因为你是第一次使用这个软件\n希望你能仔细阅读,如果阅读后按任何键进入软件”, "提示", MB_OK); ///判断用户是否首次打开程序 假如第一次打开 输出软件的详细信息 getchar();//等待用户对应 } system("cls"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);//亮蓝 while (1) { switch (ListShow_1()) { case 1: get_1: ListShow_2(); if (*p == 1)FoundStudent(File_system); if (*p == 2)AddStudent(File_system); if (*p == 3)DeleteStudent(File_system); if (*p == 4)ChooesStudent(File_system); if (*p == 5)ShowNew(File_system); if (*p == 6)break; system("cls"); goto get_1; break; case 2: get_2: ListShow_3(); if (*p == 1)NameSeatch(File_system); if (*p == 2)ClassSeatch(File_system); if (*p == 3)break; system("cls"); goto get_2; break; case 3: get_3: ListShow_4(); if (*p == 1)NumberSum(File_system); if (*p == 2)break; system("cls"); goto get_3; break; default: exit(0); } } return 0;}void FoundStudent(char *File_system){ char File_[100]; //自定义文件地址 char Name_[20]; ///文件名称 int number[9] = { 31,31,31,31,31,31,31,31 };///科目选择 int sum = 0; //科目数 cout << 请输入文件保存地址(例如) D:我的软件\学生管理系统 地址中不存在空间”; cin >> File_; if (_access(File_, 00) == 0) { MessageBoxA(NULL, 指定地址成功!", “欢迎使用”, MB_OK); } else { MessageBoxA(NULL, “输入路径不存在,为您创建路径!接下来,请输入文件名(文件名后缀请写为.ini)", “欢迎使用”, MB_OK); _mkdir(File_);///如果路径中没有指定的文件夹,则创建文件夹 } cout << “请输入文件名:”; cin >> Name_; strcat_s(File_, "\\"); strcat_s(File_, Name_);///将文件名复制到路径后面 system("cls"); cout << " ╔══════════════════════════════════════════╗\n"; cout << " ║══ ①语文 ══ ②数学 ══ ③英语 ══ ④政治 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ⑤历史 ══ ⑥地理 ══ ⑦生物 ══ ⑧物理 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ⑨化学 ║\n"; cout << " ╚══════════════════════════════════════════╝\n"; MessageBoxA(NULL, “选择科目(选择一次回车\n至少选择三个科目\n,如果不选择,请输入0) “欢迎使用”, MB_OK); ofstream fout_1(File_); //默认调用方法 ofstream显式 fout.open(File_); fout_1.close(); ofstream fout(File_system); fout << "[FILE]" << endl; ///分配文件地址和名称 fout << "地址=" << File_ << endl; fout << "[SUBGECT]" << endl;//分配科目 for (int i = 0; i < 9; i++) { cin >> number[i]; if (number[i] != 0)sum += 1; if (number[i] == 0) { number[i] = 31; break; } } for (int i = 0; i < 9; i++) { fout << “科目代码” << i + 1 << "=" << number[i] << endl; } fout << “科目总数=” << sum << endl; fout << ""[记录人数]" << endl; fout << "total=0" << endl; fout << “[是否第一次打开]” << endl; fout << "Frist=1" << endl; fout << “[是否第一次记录]” << endl; fout << "F=0" << endl; fout.close(); cout << “学生成绩表已经建立” << endl; cout << “立即添加学生信息(1), 返回上一级菜单(0) << endl; int CinJ = 0; cin >> CinJ; if (CinJ == 1) { system("cls"); AddStudent(File_system); } ///当程序正常运行时 代表返回上一层}void AddStudent(char * File_system){ char * Studata = NULL; Studata = new char[20]; //信息 char * NUM_1 = NULL; NUM_1 = new char[100]; char File_[100]; //阅读文件地址 int ReturnSu = 0; ///阅读科目数 int total; //////阅读记录的总人数 char * total_f = NULL; total_f = new char[1000]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); ReturnSu = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); int number[9]; ///存储File_system配置文件中存储的科目 for (int i = 0; i < 9; i++) ////为number提供数据 { char Name[30] = “科目代码”; switch (i) { case 1: Function_1(i, Name); break; case 2: Function_1(i, Name); break; case 3: Function_1(i, Name); break; case 4: Function_1(i, Name); break; case 5: Function_1(i, Name); break; case 6: Function_1(i, Name); break; case 7: Function_1(i, Name); break; case 8: Function_1(i, Name); break; } char *stu_ = Name; number[i] = GetPrivateProfileIntA("SUBGECT", stu_, -1, File_system); } cout << “已选科目,请按以下格式记录学生信息:n"; SubjectJudge(number); ///显示需要输入的内容 MessageBoxA(NULL, “请严格按照上述信息顺序输入\n输入学生信息,然后按回车\n输入信息,请用空格隔开\n输入下一个学生信息,请输入\"T\"结束", "提示", MB_OK); ofstream fout(File_, ios::ate | ios::app); ///阅读文件 for (int j = total + 1; j <= 1000; j++) { sprintf(NUM_1, "%d", j); if (strcmp(Studata, "T") == 0) { break; } for (int i = 1; i <= ReturnSu + 3; i++) { cin >> Studata; if (i == 1) { if (strcmp(Studata, "T") == 0) //如果输入T,则退出 { break; } WritePrivateProfileStringA(NUM_1, "姓名", Studata, File_); total += 1; sprintf(total_f, "%d", total); //int 转 字符串 WritePrivateProfileStringA(记录人数”, "total", total_f, File_system); } if (i == 2) { WritePrivateProfileStringA(NUM_1, "学号", Studata, File_); } if (i == 3) { WritePrivateProfileStringA(NUM_1, "班级", Studata, File_); } if (i == 4) { WritePrivateProfileStringA(NUM_1, "语文", Studata, File_); } if (i == 5) { WritePrivateProfileStringA(NUM_1, "数学", Studata, File_); } if (i == 6) { WritePrivateProfileStringA(NUM_1, "英语", Studata, File_); } if (i == 7) { WritePrivateProfileStringA(NUM_1, "政治", Studata, File_); } if (i == 8) { WritePrivateProfileStringA(NUM_1, "历史", Studata, File_); } if (i == 9) { WritePrivateProfileStringA(NUM_1, "地理", Studata, File_); } if (i == 10) { WritePrivateProfileStringA(NUM_1, "生物", Studata, File_); } if (i == 11) { WritePrivateProfileStringA(NUM_1, "物理", Studata, File_); } if (i == 12) { WritePrivateProfileStringA(NUM_1, "化学", Studata, File_); } WritePrivateProfileStringA(”是否第一次记录, "F", "1", File_system); } } fout.close(); ///关闭文件 delete[]Studata; delete[]NUM_1; delete[]total_f; cout << “信息已录入” << endl; cout<<“返回上一级菜单(任意键)<<endl; int e; cin >> e;}void DeleteStudent(char * File_system){ char File_[100]; //阅读文件地址 int total; //////阅读记录的总人数 int N; //获取科目数 int F; //获取记录 char CH[10]; /////获得的字符类型 int IN_; //获取的数字类型 int * percase = NULL; //记录删除标号 percase = new int[sizeof(int) * 100]; int persum = 0; //记录删除人数 char * SuIT = NULL; SuIT = new char[20]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); F = GetPrivateProfileIntA(”是否第一次记录, "F", -1, File_system); if (F == -1)MessageBoxA(NULL, “你没有记录任何学生信息,不能删除”, "消息", MB_OK); if (F == 0) MessageBoxA(NULL, “你没有记录任何学生信息,不能删除”, "消息", MB_OK); if (F == 1) { for (int j = 1; j <= total; j++) { int sum = 0; ///不合格科目 char Delename[50] = ""; for (int i = 1; i <= N + 3; i++) { char CH_F[10];///数字转字符 sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "未知", CH, sizeof(CH), File_); strcat(Delename, CH); strcat(Delename, " "); } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60) sum += 1; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); sprintf(CH_F, "%d", IN_); strcat(Delename, CH_F); strcat(Delename, " "); if (IN_ <= 60)sum += 1; } } if (sum >= 3) ///如果不及格的科目超过三门,打印同学的信息 { cout << Delename; cout << endl; percase[persum] = j; persum += 1;///删除人数 } } } if (IDYES == MessageBoxA(NULL, 是否删除\\n 按 \"确认删除", “新闻(花狗制作)” MB_YESNO)) { for (int j = 1; j <= persum; j++) { char LS[10]; sprintf(LS, "%d", percase[j - 1]); WritePrivateProfileStringA(LS, NULL, NULL, File_); } } else { cout << “您已取消删除..."; } delete[]percase; delete[]SuIT; cout << “信息已处理完毕(任意键返回菜单)” << endl; int e; cin >> e;}void ChooesStudent(char * File_system){ int Stunumer = 0; //获得的学生学号 char File_[100]; //阅读文件地址 char CH[10]; /////获得的字符类型 int IN_; //获取的数字类型 char CH_[20]; int total; //////阅读记录的总人数 int N; //获取科目数 char * SuIT = NULL; SuIT = new char[20]; int a = 0; //当找到信息时,如果没有学号信息,a为0,提示输入错误是否再次输入 char CH_1[20]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); cout << 输入学号修改学生信息n"; cin >> Stunumer; for (int j = 1; j <= total; j++) { sprintf(CH_1, "%d", j); a = GetPrivateProfileIntA(CH_1, "学号", -1, File_); if (Stunumer == a) { for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); cout << "姓名:"; cout << CH << endl; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); cout << "学号:"; cout << IN_ << endl; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); cout << "班级:"; cout << IN_ << endl; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改语文成绩\n? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "语文", CH_, File_); } } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); if (IDYES == MessageBoxA(NULL, 数学成绩是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "数学", CH_, File_); } } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); if (IDYES == MessageBoxA(NULL, 英语成绩是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "英语", CH_, File_); } } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改政治成果\n? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "政治", CH_, File_); } } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改历史成就\n \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "历史", CH_, File_); } } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); if (IDYES == MessageBoxA(NULL, 地理成绩是否被修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "地理", CH_, File_); } } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); if (IDYES == MessageBoxA(NULL, "是否修改生物成分\n? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "生物", CH_, File_); } } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); if (IDYES == MessageBoxA(NULL, 物理成绩\n是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "物理", CH_, File_); } } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); if (IDYES == MessageBoxA(NULL, 化学成绩是否修改? \"是\" 修改 按 \"否\" 进入下一个修改, "消息", MB_YESNO)) { cin >> IN_; sprintf(CH_, "%d", IN_); WritePrivateProfileStringA(SuIT, "化学", CH_, File_); } } } ++a; } } delete[]SuIT; cout << “信息已修改(任意键返回菜单)” << endl; int e; cin >> e;}void ShowNew(char * File_system){ char File_[100]; //阅读文件地址 int total; //////阅读记录的总人数 int N; //获取科目数 int F; //获取记录 char CH[10]; /////获得的字符类型 int IN_; //获取的数字类型 char * SuIT = NULL; SuIT = new char[20]; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); F = GetPrivateProfileIntA(”是否第一次记录, "F", -1, File_system); if (F == -1)MessageBoxA(NULL, “你没有记录任何学生信息”, "消息", MB_OK); if (F == 0) MessageBoxA(NULL, “你没有记录任何学生信息”, "消息", MB_OK); if (F == 1) { for (int j = 1; j <= total; j++) { int a = 0; for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); if (strcmp(CH, "error") != 0)cout << CH << " "; else ++a; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); if (IN_ != -1)cout << IN_ << " "; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); if (IN_ != -1)cout << IN_ << " "; } } if (a == 0)cout << endl; } } delete[]SuIT; cout << “信息已查阅(任意键返回菜单)” << endl; int e; cin >> e;}void NameSeatch(char * File_system){ char Stunumer[10]; //获得的学生姓名 char File_[100]; //阅读文件地址 char CH[10]; /////获得的字符类型 char CH_[20]; char CH_1[20]; int IN_; //获取的数字类型 int total; //////阅读记录的总人数 int N; //获取科目数 char * SuIT = NULL; SuIT = new char[20]; int a = 0; //当找到信息时,如果没有学号信息,a为0,提示输入错误是否再次输入 int b = 0; GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); cout << 输入学生姓名查看学生信息n"; while (1) { cin >> Stunumer; b = 0; for (int j = 1; j <= total; j++) { sprintf(CH_1, "%d", j); GetPrivateProfileStringA(CH_1, "姓名", "未知", CH_, sizeof(CH_), File_); if (strcmp(Stunumer, CH_) == 0) { for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); cout << "姓名:"; cout << CH << endl; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); cout << "学号:"; cout << IN_ << endl; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); cout << "班级:"; cout << IN_ << endl; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); cout << "语文:"; cout << IN_ << endl; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); cout << "数学:"; cout << IN_ << endl; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); cout << "英语:"; cout << IN_ << endl; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); cout << "政治:"; cout << IN_ << endl; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); cout << "历史:"; cout << IN_ << endl; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); cout << "地理:"; cout << IN_ << endl; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); cout << "生物:"; cout << IN_ << endl; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); cout << "物理:"; cout << IN_ << endl; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); cout << "化学:"; cout << IN_ << endl; } } b = 1; } } if (b == 0) { cout << “你输入的名字是错误的,或者没有学生” << endl; cout << “如果是按班级搜索,请按1,继续按姓名搜索,请按2,任意键返回上级菜单” << endl; int w; cin >> w; if (w == 1) { ClassSeatch(File_system); } if (w != 1 && w != 1 && w != 2) { cout << "tuichu"; break; } } } delete[]SuIT;}void ClassSeatch(char * File_system) { int Stunumer = 0; //获得的学生班 char File_[100]; //阅读文件地址 char CH[10]; /////获得的字符类型 char CH_1[20]; int IN_; //获取的数字类型 int total; //////阅读记录的总人数 int N=0; //获取科目数 char * SuIT = NULL; SuIT = new char[20]; int a = 0; //当找到信息时,如果没有学号信息,a为0,提示输入错误是否再次输入 int b = 0; //检查是否找到 GetPrivateProfileStringA("FILE", "地址", "未知", File_, sizeof(File_), File_system); total = GetPrivateProfileIntA(记录人数”, "total", -1, File_system); N = GetPrivateProfileIntA("SUBGECT", “科目总数”, -1, File_system); cout << 输入学生班级查看学生信息n"; while (1) { cin >> Stunumer; //获得班级 for (int j = 1; j <= total; j++) { sprintf(CH_1, "%d", j); a = GetPrivateProfileIntA(CH_1, "班级", -1, File_); if (Stunumer == a) { for (int i = 1; i <= N + 3; i++) { sprintf(SuIT, "%d", j); if (i == 1) { GetPrivateProfileStringA(SuIT, "姓名", "error", CH, sizeof(CH), File_); cout << "姓名:"; cout << CH << endl; } if (i == 2) { IN_ = GetPrivateProfileIntA(SuIT, "学号", -1, File_); cout << "学号:"; cout << IN_ << endl; } if (i == 3) { IN_ = GetPrivateProfileIntA(SuIT, "班级", -1, File_); cout << "班级:"; cout << IN_ << endl; } if (i == 4) { IN_ = GetPrivateProfileIntA(SuIT, "语文", -1, File_); cout << "语文:"; cout << IN_ << endl; } if (i == 5) { IN_ = GetPrivateProfileIntA(SuIT, "数学", -1, File_); cout << "数学:"; cout << IN_ << endl; } if (i == 6) { IN_ = GetPrivateProfileIntA(SuIT, "英语", -1, File_); cout << "英语:"; cout << IN_ << endl; } if (i == 7) { IN_ = GetPrivateProfileIntA(SuIT, "政治", -1, File_); cout << "政治:"; cout << IN_ << endl; } if (i == 8) { IN_ = GetPrivateProfileIntA(SuIT, "历史", -1, File_); cout << "历史:"; cout << IN_ << endl; } if (i == 9) { IN_ = GetPrivateProfileIntA(SuIT, "地理", -1, File_); cout << "地理:"; cout << IN_ << endl; } if (i == 10) { IN_ = GetPrivateProfileIntA(SuIT, "生物", -1, File_); cout << "生物:"; cout << IN_ << endl; } if (i == 11) { IN_ = GetPrivateProfileIntA(SuIT, "物理", -1, File_); cout << "物理:"; cout << IN_ << endl; } if (i == 12) { IN_ = GetPrivateProfileIntA(SuIT, "化学", -1, File_); cout << "化学:"; cout << IN_ << endl; } } b = 1; } } if (b==0) { cout << “你输入的班级错了,或者没有人在这个班” << endl; cout << “如果是按名字搜索,请按1,继续按班级搜索,请按2,任意键返回上级菜单” << endl; int w; cin >> w; if (w == 1) { NameSeatch(File_system); } if (w != 1 && w != 2) { cout << "tuichu"; break; } } } delete[]SuIT;}int ListShow_1(){ cout << " ╔══════════════════════════════════╗\n"; cout << " ║══ ①信息维护 ══ ②信息检索 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ③信息统计 ══ ④退出系统 ══║\n"; cout << " ╚══════════════════════════════════╝\n"; MessageBoxA(NULL, “请选择功能”, “新闻(花狗制作)” MB_OK); int num_1; cin >> num_1; ///用户选择 system("cls"); return num_1;}int ListShow_2(){ cout << " ╔════════════════════════════════════════════╗\n"; cout << " ║══ ①建立学生成绩表 ══ ②添加学生记录 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ③删除学生记录 ══ ④修改学生信息 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ⑤查看记录的信息 ══ ⑥返回上级菜单 ══║\n"; cout << " ╚════════════════════════════════════════════╝\n"; MessageBoxA(NULL, “请再次选择功能(如果不是第一次使用,请不要选择1)” “新闻(花狗制作)” MB_OK); int num_2; cin >> num_2; ///用户选择 p = &num_2; system("cls"); return num_2;}int ListShow_3(){ cout << " ╔══════════════════════════════════════╗\n"; cout << " ║══ ①按姓名查找 ══ ②按班级查找 ══║\n"; cout << " ║ ║\n"; cout << " ║══ ③返回上级菜单 ║\n"; cout << " ╚══════════════════════════════════════╝\n"; MessageBoxA(NULL, “请再次选择功能”, “新闻(花狗制作)” MB_OK); int num_2; cin >> num_2; ///用户选择 p = &num_2; system("cls"); return num_2;}int ListShow_4(){ cout << " ╔══════════════════════════════════════╗\n"; cout << " ║══ ①成绩统计 ══ ②返回上级菜单 ══║\n"; cout << " ╚══════════════════════════════════════╝\n"; MessageBoxA(NULL, “请再次选择功能”, “新闻(花狗制作)” MB_OK); int num_2; cin >> num_2; ///用户选择 p = &num_2; system("cls"); return num_2;}void ShowP(){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);//红 cout << “学校学生信息管理系统(花狗制作) QQ/VX:2506897252 仅供学习使用)\n"<< endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);//蓝 cout << “主要功能说明:” << endl; cout << 一、建立密码登录(模块a) << endl; cout << 以密码形式验证管理员身份(可输入三次),可以正确地进入密码,否则程序就结束了。" << endl; cout << “2.建立学生成绩表(模块b) << endl; cout << "建立新的学生成绩文件;" << endl; cout << “建立一些学生记录,包括姓名、学号、班级、课程、成绩,包括添加学生记录。" << endl; cout << 三、添加学生记录(模块c) << endl; cout << 在现有的学生成绩文件中添加新的记录。" << endl; cout << 4.删除学生记录(模块d) << endl; cout << “在学生成绩文件中删除三门课程不及格的学生记录;” << endl; cout << "删除前,逐一显示符合删除条件的学生姓名和成绩,确认后删除。" << endl; cout << 5.修改学生信息(模块e) << endl; cout << 输入学生学号,在学生成绩文件中找到学生记录;" << endl; cout << “学生的记录一个个显示在屏幕上;” << endl; cout << 如果“每次显示一个,询问是否修改,”Y输入修改后的数据," << endl; cout << 删除文件原记录,保存新记录;" << endl; cout << 6.根据姓名和班级搜索(模块f) << endl; cout << “输入姓名显示相应信息。" << endl; cout << 7.信息统计(模块g) << endl; cout << “同时,根据班级和课程统计每门课程和班级的平均成绩,最高分,最低分;" << endl; cout << “每门课程的统计数据首先依次显示在屏幕上,对应于每个班级。" << endl; cout << 退出信息管理系统,返回操作系统。" << endl; cout << “8.退出信息管理系统,返回操作系统。(模块h)” << endl;}void NumberSum(char * File_system){}