高考成绩查询系统

好的,高考成绩管理系统可以包含以下功能: 1. 添加学生信息 2. 删除学生信息 3. 修改学生信息 4. 查询学生信息 5. 显示所有学生信息 下面是一个简单的实现示例: “`cpp #include <iostream> #include <vector> #include <algorithm> #include <iomanip> using namespace std; struct Student { string name; int id; int score; }; vector<Student> students; void add_student() { Student s; cout << "请输入学生姓名:"; cin >> s.name; cout << "请输入学生学号:"; cin >> s.id; cout << "请输入学生分数:"; cin >> s.score; students.push_back(s); cout << "添加成功!" << endl; } void delete_student() { int id; cout << "请输入要删除的学生学号:"; cin >> id; auto iter = find_if(students.begin(), students.end(), [id](const Student& s) { return s.id == id; }); if (iter != students.end()) { students.erase(iter); cout << "删除成功!" << endl; } else { cout << "未找到该学生!" << endl; } } void modify_student() { int id; cout << "请输入要修改的学生学号:"; cin >> id; auto iter = find_if(students.begin(), students.end(), [id](const Student& s) { return s.id == id; }); if (iter != students.end()) { cout << "请输入修改后的学生信息:" << endl; cout << "姓名:"; cin >> iter->name; cout << "学号:"; cin >> iter->id; cout << "分数:"; cin >> iter->score; cout << "修改成功!" << endl; } else { cout << "未找到该学生!" << endl; } } void query_student() { int id; cout << "请输入要查询的学生学号:"; cin >> id; auto iter = find_if(students.begin(), students.end(), [id](const Student& s) { return s.id == id; }); if (iter != students.end()) { cout << "学生姓名:" << iter->name << endl; cout << "学生学号:" << iter->id << endl; cout << "学生成绩:" << iter->score << endl; } else { cout << "未找到该学生!" << endl; } } void show_students() { if (students.size() == 0) { cout << "暂无学生信息!" << endl; return; } cout << left << setw(10) << "姓名" << setw(10) << "学号" << setw(10) << "分数" << endl; for (auto& s : students) { cout << left << setw(10) << s.name << setw(10) << s.id << setw(10) << s.score << endl; } } int main() { int choice; do { cout << "请选择要进行的操作:" << endl; cout << "1. 添加学生信息" << endl; cout << "2. 删除学生信息" << endl; cout << "3. 修改学生信息" << endl; cout << "4. 查询学生信息" << endl; cout << "5. 显示所有学生信息" << endl; cout << "0. 退出程序" << endl; cin >> choice; switch (choice) { case 1: add_student(); break; case 2: delete_student(); break; case 3: modify_student(); break; case 4: query_student(); break; case 5: show_students(); break; case 0: cout << "程序已退出!" << endl; break; default: cout << "输入有误,请重新选择!" << endl; break; } } while (choice != 0); return 0; } “` 这里使用了 STL 中的 vector,以及算法函数 find_if 和 erase。在 main 函数中,使用 do-while 循环来实现菜单选择。

原文链接:https://blog.csdn.net/W12_3456789/article/details/123476998?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171910925216800227448716%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=171910925216800227448716&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-17-123476998-null-null.nonecase&utm_term=2024%E9%AB%98%E8%80%83%E6%9F%A5%E5%88%86

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享