学生学籍管理系统(必须使用C++)

用数据文件存放学生的学籍,可对学生学籍进行注册,登录,修改,删除,查找,统计,学籍变化等操作。(用文件保存)功能要求:

(1)系统以菜单方式工作。

(2)登记学生的学号,姓名,性别,年龄,籍贯,系别,专业,班级;修改已知学号的学生信息;

(3)删除已知学号的学生信息;

(4)查找已知学号的学生信息;

(5)按学号,专业输出学生籍贯表。

(6)查询学生学籍变化,比如入学,转专业,退学,降级,休学,毕业

最后再附一份报告


以下是一个简单的学生学籍管理系统的 C++ 代码示例,实现了您提到的功能要求:

cpp
Copy Code
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

struct Student {
    string id;
    string name;
    string gender;
    int age;
    string nativePlace;
    string department;
    string major;
    string className;
};

vector<Student> students;

void saveStudentsToFile() {
    ofstream file("students.txt");
    for (const auto& student : students) {
        file << student.id << "," << student.name << "," << student.gender << "," << student.age << ","
             << student.nativePlace << "," << student.department << "," << student.major << "," << student.className << endl;
    }
    file.close();
}

void loadStudentsFromFile() {
    ifstream file("students.txt");
    if (!file) {
        cout << "No existing data file found." << endl;
        return;
    }

    students.clear();

    string line;
    while (getline(file, line)) {
        Student student;
        size_t pos = 0;
        string token;
        int field = 0;
        while ((pos = line.find(',')) != string::npos) {
            token = line.substr(0, pos);
            switch (field) {
                case 0: student.id = token; break;
                case 1: student.name = token; break;
                case 2: student.gender = token; break;
                case 3: student.age = stoi(token); break;
                case 4: student.nativePlace = token; break;
                case 5: student.department = token; break;
                case 6: student.major = token; break;
                case 7: student.className = token; break;
                default: break;
            }
            line.erase(0, pos + 1);
            field++;
        }
        students.push_back(student);
    }

    file.close();
}

void registerStudent() {
    Student student;
    cout << "Enter student ID: ";
    cin >> student.id;
    cout << "Enter student name: ";
    cin >> student.name;
    cout << "Enter student gender: ";
    cin >> student.gender;
    cout << "Enter student age: ";
    cin >> student.age;
    cout << "Enter student native place: ";
    cin >> student.nativePlace;
    cout << "Enter student department: ";
    cin >> student.department;
    cout << "Enter student major: ";
    cin >> student.major;
    cout << "Enter student class name: ";
    cin >> student.className;

    students.push_back(student);

    saveStudentsToFile();

    cout << "Student registered successfully." << endl;
}

void modifyStudentInfo() {
    string id;
    cout << "Enter student ID: ";
    cin >> id;

    bool found = false;
    for (auto& student : students) {
        if (student.id == id) {
            cout << "Enter new student name: ";
            cin >> student.name;
            cout << "Enter new student gender: ";
            cin >> student.gender;
            cout << "Enter new student age: ";
            cin >> student.age;
            cout << "Enter new student native place: ";
            cin >> student.nativePlace;
            cout << "Enter new student department: ";
            cin >> student.department;
            cout << "Enter new student major: ";
            cin >> student.major;
            cout << "Enter new student class name: ";
            cin >> student.className;

            saveStudentsToFile();

            cout << "Student information modified successfully." << endl;

            found = true;
            break;
        }
    }

    if (!found) {
        cout << "No student found with the given ID." << endl;
    }
}

void deleteStudent() {
    string id;
    cout << "Enter student ID: ";
    cin >> id;

    for (auto it = students.begin(); it != students.end(); ++it) {
        if (it->id == id) {
            students.erase(it);
            saveStudentsToFile();
            cout << "Student deleted successfully." << endl;
            return;
        }
    }

    cout << "No student found with the given ID." << endl;
}

void searchStudent() {
    string id;
    cout << "Enter student ID: ";
    cin >> id;

    for (const auto& student : students) {
        if (student.id == id) {
            cout << "Student Information:" << endl;
            cout << "ID: " << student.id << endl;
            cout << "Name: " << student.name << endl;
            cout << "Gender: " << student.gender << endl;
            cout << "Age: " << student.age << endl;
            cout << "Native Place: " << student.nativePlace << endl;
            cout << "Department: " << student.department << endl;
            cout << "Major: " << student.major << endl;
            cout << "Class Name: " << student.className << endl;
            return;
        }
    }

    cout << "No student found with the given ID." << endl;
}

void outputNativePlacesByMajor() {
    string major;
    cout << "Enter major: ";
    cin >> major;

    cout << "Native Places of Students in " << major << ":" << endl;

    for (const auto& student : students) {
        if (student.major == major) {
            cout << student.nativePlace << endl;
        }
    }
}

int main() {
    loadStudentsFromFile();

    int choice;
    do {
        cout << "Student Management System" << endl;
        cout << "-------------------------" << endl;
        cout << "1. Register Student" << endl;
        cout << "2. Modify Student Information" << endl;
        cout << "3. Delete Student" << endl;
        cout << "4. Search Student" << endl;
        cout << "5. Output Native Places by Major" << endl;
        cout << "0. Exit" << endl;
        cout << "Enter your choice: ";
        cin >> choice;

        switch (choice) {
            case 1:
                registerStudent();
                break;
            case 2:
                modifyStudentInfo();
                break;
            case 3:
                deleteStudent();
                break;
            case 4:
                searchStudent();
                break;
            case 5:
                outputNativePlacesByMajor();
                break;
            case 0:
                cout << "Exiting the program..." << endl;
                break;
            default:
                cout << "Invalid choice. Please try again." << endl;
                break;
        }

        cout << endl;
    } while (choice != 0);

    return 0;
}
在该示例代码中,学生的学籍信息通过一个结构体 Student 来表示。程序使用一个动态数组 students 来保存所有学生的信息,并通过文件 students.txt 进行持久化存储。

请注意,在运行程序之前,确保当前目录下存在 students.txt 文件,以便能够正确读取和保存学生的学籍信息。

此外,还需要在某些功能函数中添加适当的错误处理或验证输入的代码,以增强程序的稳定性和鲁棒性。

至于报告的编写,您可以根据这个学生学籍管理系统的设计和实现过程,撰写一个包含以下内容的报告:

引言:介绍学生学籍管理系统的目的和重要性,以及开发此系统的动机。

功能需求:列出学生学籍管理系统的功能需求,例如注册、登录、修改、删除、查找、统计等。

系统设计:描述使用的数据结构、算法和文件存储方式,解释如何实现系统中的每个功能要求。

用户界面:展示菜单式用户界面,说明系统如何与用户交互以完成各项操作。

实现细节:讨论程序中的关键代码段、算法或其他实现细节,包括文件读写、数据处理等。

测试和验证:描述对系统进行的测试和验证过程,确保系统能够按照预期工作,并满足功能需求。

总结和展望:总结整个项目,讨论系统的优点和不足之处,并提供对未来扩展或改进的展望。

请注意,以上只是一个简单的示例代码和报告的框架,您可以根据实际需要进行修改和完善。
万方有相关学位论文,需要可以单独联系我

基于new bing部分指引作答:

img

以下是一个使用C++编写的简单学生学籍管理系统示例,它满足您提供的功能要求:

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

struct Student {
    string id;
    string name;
    string gender;
    int age;
    string hometown;
    string department;
    string major;
    string className;
};

// 函数声明
void displayMenu();
void registerStudent(vector<Student>& students);
void modifyStudent(vector<Student>& students);
void deleteStudent(vector<Student>& students);
void searchStudent(vector<Student>& students);
void printHometownByMajor(const vector<Student>& students);
void printStudentChanges(const vector<Student>& students);

// 保存学生信息到文件
void saveToFile(const vector<Student>& students) {
    ofstream file("students.txt");
    if (file.is_open()) {
        for (const auto& student : students) {
            file << student.id << ","
                 << student.name << ","
                 << student.gender << ","
                 << student.age << ","
                 << student.hometown << ","
                 << student.department << ","
                 << student.major << ","
                 << student.className << endl;
        }
        file.close();
        cout << "学生信息保存成功!" << endl;
    } else {
        cout << "无法打开文件!" << endl;
    }
}

// 从文件加载学生信息
void loadFromFile(vector<Student>& students) {
    ifstream file("students.txt");
    if (file.is_open()) {
        string line;
        while (getline(file, line)) {
            Student student;
            size_t pos = 0;
            string token;
            int count = 0;

            while ((pos = line.find(",")) != string::npos) {
                token = line.substr(0, pos);
                switch (count) {
                    case 0: student.id = token; break;
                    case 1: student.name = token; break;
                    case 2: student.gender = token; break;
                    case 3: student.age = stoi(token); break;
                    case 4: student.hometown = token; break;
                    case 5: student.department = token; break;
                    case 6: student.major = token; break;
                    case 7: student.className = token; break;
                }
                line.erase(0, pos + 1);
                count++;
            }

            students.push_back(student);
        }
        file.close();
        cout << "学生信息加载成功!" << endl;
    } else {
        cout << "无法打开文件!" << endl;
    }
}

int main() {
    vector<Student> students;
    loadFromFile(students);

    int choice;
    do {
        displayMenu();
        cin >> choice;
        cin.ignore(); // 忽略输入缓冲区中的换行符

        switch (choice) {
            case 1: registerStudent(students); break;
            case 2: modifyStudent(students); break;
            case 3: deleteStudent(students); break;
            case 4: searchStudent(students); break;
            case 5: printHometownByMajor(students); break;
            case 6: printStudentChanges(students); break;
            case 0: break;
            default: cout << "无效的选择,请重试!" << endl;
        }

        saveToFile(students);
        cout << endl;
    } while (choice != 0);

    return 0;
}

void displayMenu() {
    cout << "============== 学生学籍管理系统 ==============" << endl;
    cout << "1. 注册学生学籍" << endl;
    cout << "2. 修改学生学籍" << endl;
    cout << "3. 删除学生学籍" << endl;
    cout << "4. 查找学生学籍" << endl;
    cout << "5. 按专业输出学生籍贯表" << endl;
    cout << "6. 查询学生学籍变化" << endl;
    cout << "0. 退出系统" << endl;
    cout << "=============================================" << endl;
    cout << "请输入操作编号:";
}

void registerStudent(vector<Student>& students) {
    Student student;
    cout << "请输入学生学号:";
    getline(cin, student.id);

    for (const auto& s : students) {
        if (s.id == student.id) {
            cout << "该学号已存在!" << endl;
            return;
        }
    }

    cout << "请输入学生姓名:";
    getline(cin, student.name);
    cout << "请输入学生性别:";
    getline(cin, student.gender);
    cout << "请输入学生年龄:";
    cin >> student.age;
    cin.ignore();
    cout << "请输入学生籍贯:";
    getline(cin, student.hometown);
    cout << "请输入学生系别:";
    getline(cin, student.department);
    cout << "请输入学生专业:";
    getline(cin, student.major);
    cout << "请输入学生班级:";
    getline(cin, student.className);

    students.push_back(student);

    cout << "学生注册成功!" << endl;
}

void modifyStudent(vector<Student>& students) {
    string id;
    cout << "请输入要修改的学生学号:";
    getline(cin, id);

    for (auto& student : students) {
        if (student.id == id) {
            cout << "请输入学生姓名:";
            getline(cin, student.name);
            cout << "请输入学生性别:";
            getline(cin, student.gender);
            cout << "请输入学生年龄:";
            cin >> student.age;
            cin.ignore();
            cout << "请输入学生籍贯:";
            getline(cin, student.hometown);
            cout << "请输入学生系别:";
            getline(cin, student.department);
            cout << "请输入学生专业:";
            getline(cin, student.major);
            cout << "请输入学生班级:";
            getline(cin, student.className);

            cout << "学生信息修改成功!" << endl;
            return;
        }
    }

    cout << "找不到学号为 " << id << " 的学生!" << endl;
}

void deleteStudent(vector<Student>& students) {
    string id;
    cout << "请输入要删除的学生学号:";
    getline(cin, id);

    for (auto it = students.begin(); it != students.end(); ++it) {
        if (it->id == id) {
            students.erase(it);
            cout << "学生信息删除成功!" << endl;
            return;
        }
    }

    cout << "找不到学号为 " << id << " 的学生!" << endl;
}

void searchStudent(vector<Student>& students) {
    string id;
    cout << "请输入要查找的学生学号:";
    getline(cin, id);

    for (const auto& student : students) {
        if (student.id == id) {
            cout << "学号:" << student.id << endl;
            cout << "姓名:" << student.name << endl;
            cout << "性别:" << student.gender << endl;
            cout << "年龄:" << student.age << endl;
            cout << "籍贯:" << student.hometown << endl;
            cout << "系别:" << student.department << endl;
            cout << "专业:" << student.major << endl;
            cout << "班级:" << student.className << endl;
            return;
        }
    }

    cout << "找不到学号为 " << id << " 的学生!" << endl;
}

void printHometownByMajor(const vector<Student>& students) {
    string major;
    cout << "请输入要输出学籍贯表的专业:";
    getline(cin, major);

    cout << "专业为 " << major << " 的学生籍贯表:" << endl;
    for (const auto& student : students) {
        if (student.major == major) {
            cout << "学号:" << student.id << ",籍贯:" << student.hometown << endl;
        }
    }
}

void printStudentChanges(const vector<Student>& students) {
    string id;
    cout << "请输入要查询学籍变化的学生学号:";
    getline(cin, id);

    for (const auto& student : students) {
        if (student.id == id) {
            cout << "学生 " << student.name << "(学号:" << student.id << ")的学籍变化:" << endl;
            cout << "1. 入学" << endl;
            cout << "2. 转专业" << endl;
            cout << "3. 退学" << endl;
            cout << "4. 降级" << endl;
            cout << "5. 休学" << endl;
            cout << "6. 毕业" << endl;
            cout << "请选择学籍变化编号:";

            int choice;
            cin >> choice;
            cin.ignore();

            switch (choice) {
                case 1: cout << "学生 " << student.name << " 入学" << endl; break;
                case 2: cout << "学生 " << student.name << " 转专业" << endl; break;
                case 3: cout << "学生 " << student.name << " 退学" << endl; break;
                case 4: cout << "学生 " << student.name << " 降级" << endl; break;
                case 5: cout << "学生 " << student.name << " 休学" << endl; break;
                case 6: cout << "学生 " << student.name << " 毕业" << endl; break;
                default: cout << "无效的选择!" << endl;
            }

            return;
        }
    }

    cout << "找不到学号为 " << id << " 的学生!" << endl;
}

这个程序使用students.txt文件存储学生的学籍信息。每行表示一个学生的信息,字段之间使用逗号分隔。

好的,您需要实现一个C++程序,用于对学生学籍进行管理,并以文件方式保存数据。以下是一个可以参考的实现步骤:

  1. 定义一个学生结构体,包含学号、姓名、性别、年龄、籍贯、系别、专业、班级等信息。

  2. 定义一个文件读写类,用于读写学生信息到文件中。

  3. 实现菜单功能,当运行程序时,显示菜单选项,包括注册学生信息、登录、修改、删除、查找、统计、输出籍贯表、查询学籍变化等功能。

  4. 根据选择的菜单项,通过文件读写类将学生信息读写到文件中。

  5. 实现查找学生信息的功能,可以根据学号查找学生信息,并输出该学生的所有信息。

  6. 实现修改学生信息的功能,先根据学号查找到该学生信息,然后允许用户修改部分或全部信息。

  7. 实现删除学生信息的功能,根据学号查找到该学生信息,然后从文件中删除该学生信息。

  8. 实现统计学生信息的功能,可以根据专业统计学生人数、平均年龄等信息。

  9. 实现输出籍贯表的功能,可以按学号、专业输出学生籍贯表。

  10. 实现查询学籍变化的功能,可以根据学号查询学生的学籍变化,比如入学、转专业、退学、降级、休学、毕业等。

  11. 最后,编写一个报告,详细说明程序的实现过程、遇到的问题和解决方法、程序的使用说明等内容。

希望这些步骤可以帮助您完成学生学籍管理系统的开发。

[C++]学生学籍管理系统_学生学籍管理系统代码c++_甘樂哟的博客-CSDN博客 实验项目名称学生学籍管理系统一、实验目的通过设计一个小型的应用系统,使学生进一步掌握面向对象的程序设计方法,运用C++中的类与对象的概念结合面向对象程序设计的思想,独立完成应用系统的设计,并养成良好的编程习惯。通过这个实践教学平台,培养学生对计算机应用系统的综合设计能力,培养学生正确分析和解决问题的能力,了解系统开发的过程,逐步熟悉程序设计的方法。二、实验要求设计一个程序,对学生的学籍信息进行管理。通过该系统实现对学生基本信息的录入、保存、删除、修改、查询等操作。设计要求及提示如下:1、学生_学生学籍管理系统代码c++ https://blog.csdn.net/osusoer/article/details/107265042

#include<bits/stdc++.h>
using namespace std;
struct Stu//储存学生信息;
{
      int num;//学号
      string name;//名字
      string sex;//性别
      int year;//年龄
      int grade;//班级
      string major;//专业
};
class Student
{
public:
      Stu a[100];
      int len;
      void file_cin()//从XS.txt中读取数据
      {
            freopen("XS.txt", "r", stdin);//重定向
            int n;cin>>n;
            len = n;
            for (int i=1; i<=n; i++)
            {
                  cin>>a[i].num>>a[i].name>>a[i].sex>>a[i].year>>a[i].grade>>a[i].major;
            }
            freopen("CON", "r", stdin);//关闭重定向
      }
      void stu_cin()//录入函数
      {
            len++;
            cout << "学号: ";
            cin>>a[len].num;
            cout << "姓名: ";
            cin>>a[len].name;
            cout << "性别: ";
            cin>>a[len].sex;
            cout << "年龄: ";
            cin>>a[len].year;
            cout << "班级: ";
            cin>>a[len].grade;
            cout << "专业: ";
            cin>>a[len].major;
      }
      void stu_delete(int n)//删除函数
      {
            for (int i=n; i<len; i++)
            {
                  a[i].num=a[i+1].num;
                  a[i].name=a[i+1].name;
                  a[i].sex=a[i+1].sex;
                  a[i].year=a[i+1].year;
                  a[i].grade=a[i+1].grade;
                  a[i].major=a[i+1].major;
            }
            len--;
      }
      void stu_show()//输出到运行框上
      {
            for (int i=1; i<=len; i++)
            {
                  cout << i  << " ";
                  cout << a[i].num  << " ";
                  cout << a[i].name  << " ";
                  cout << a[i].sex  << " ";
                  cout << a[i].year  << " ";
                  cout << a[i].grade  << " ";
                  cout << a[i].major  << endl;
            }
      }
      void stu_vodify(int i)//修改函数
      {
            cout << a[i].num << " "
            << a[i].name << " "
            << a[i].sex << " "
            << a[i].year << " "
            << a[i].grade << " "
            << a[i].major <<endl;
            cin>>a[i].num
            >>a[i].name
            >>a[i].sex
            >>a[i].year
            >>a[i].grade
            >>a[i].major;
      }
      void stu_check(int flag)//查找函数
      {
            if (flag==1)//按学号查询单个学生信息
            {
                  cout << "请输入学号: ";
                  int temp;cin>>temp;
                  int judge=0;
                  for (int i=1; i<=len; i++)
                  {
                        if (a[i].num==temp)
                        {
                              cout << a[i].num << " "
                              << a[i].name << " "
                              << a[i].sex << " "
                              << a[i].year << " "
                              << a[i].grade << " "
                              << a[i].major <<endl;
                              judge=1;
                        }
                  }
                  if (judge==0)cout << "数据库中午该学生信息! " << endl;
            }
            else if (flag==2)//按姓名查询单个学生信息
            {
                  cout << "请输入姓名: ";
                  string temp;cin>>temp;
                  int judge=0;
                  for (int i=1; i<=len; i++)
                  {
                        if (a[i].name==temp)
                        {
                              cout << a[i].num << " "
                              << a[i].name << " "
                              << a[i].sex << " "
                              << a[i].year << " "
                              << a[i].grade << " "
                              << a[i].major <<endl;
                              judge=1;
                        }
                  }
                  if (judge==0)cout << "数据库中午该学生信息! " << endl;
            }
            else if (flag==3)//按性别查询学生信息
            {
                  cout << "请输入性别: ";
                  string temp;cin>>temp;
                  int judge=0;
                  for (int i=1; i<=len; i++)
                  {
                        if (a[i].sex==temp)
                        {
                              cout << a[i].num << " "
                              << a[i].name << " "
                              << a[i].sex << " "
                              << a[i].year << " "
                              << a[i].grade << " "
                              << a[i].major <<endl;
                              judge=1;
                        }
                  }
                  if (judge==0)cout << "数据库中午该学生信息! " << endl;
            }
            else if (flag==4)//按班号查询学生信息
            {
                  cout << "请输入班别: ";
                  int temp;cin>>temp;
                  int judge=0;
                  for (int i=1; i<=len; i++)
                  {
                        if (a[i].grade==temp)
                        {
                              cout << a[i].num << " "
                              << a[i].name << " "
                              << a[i].sex << " "
                              << a[i].year << " "
                              << a[i].grade << " "
                              << a[i].major <<endl;
                              judge=1;
                        }
                  }
                  if (judge==0)cout << "数据库中午该学生信息! " << endl;
            }
      }
      void stu_cal(int flag)//统计函数
      {
            if (flag==1)//按性别统计学生人数
            {
                  map<string ,int> ans;
                  for (int i=1; i<=len; i++)
                  {
                        ans[a[i].sex]++;
                  }
                  map<string ,int >::iterator it;
                  for (it=ans.begin(); it!=ans.end(); it++)
                  {
                        cout << it->first << " " << it->second << endl;
                  }
            }
            else if (flag==2)//按班号统计学生人数
            {
                  map<int ,int> ans;
                  for (int i=1; i<=len; i++)
                  {
                        ans[a[i].grade]++;
                  }
                  map<int ,int >::iterator it;
                  for (it=ans.begin(); it!=ans.end(); it++)
                  {
                        cout << it->first << " " << it->second << endl;
                  }
            }
            else if (flag==3)//按年龄统计学生人数
            {
                  map<int ,int> ans;
                  for (int i=1; i<=len; i++)
                  {
                        ans[a[i].year]++;
                  }
                  map<int ,int >::iterator it;
                  for (it=ans.begin(); it!=ans.end(); it++)
                  {
                        cout << it->first << " " << it->second << endl;
                  }
            }
            else if (flag==4)//按系别统计学生人数
            {
                  map<string ,int> ans;
                  for (int i=1; i<=len; i++)
                  {
                        ans[a[i].major]++;
                  }
                  map<string ,int >::iterator it;
                  for (it=ans.begin(); it!=ans.end(); it++)
                  {
                        cout << it->first << " " << it->second << endl;
                  }
            }
      }
      void save()//输出到XS.txt
      {
            ofstream file("XS.txt", ios::trunc);
            file << len << endl;
            for (int i=1; i<=len; i++)
            {
                        file << a[i].num  << " ";
                        file << a[i].name  << " ";
                        file << a[i].sex  << " ";
                        file << a[i].year  << " ";
                        file << a[i].grade  << " ";
                        file << a[i].major  << endl;
            }
            file.close();
      }
};
void print_windows()//打印选择功能界面
{
      cout << "\t\t\t\t\t\t\t学生学籍管理系统" << endl << endl << endl;
      cout << "\t\t\t\t(1)学生基本信息的录入。\t(2)学生基本信息的删除。" << endl<< endl << endl;
      cout <<"\t\t\t\t(3)学生基本信息的修改。\t(4)学生基本信息的查询。" << endl<< endl << endl;
      cout << "\t\t\t\t(5)学生基本信息的统计。\t(6)退出系统。" << endl << endl << endl;
}


int main()
{
      Student stu;//实例化
      stu.file_cin();//输入系统数据
      print_windows();//打印选择功能界面
      int flag;//用户选择的功能
      while(cin>>flag)
      {
            system("cls");
            if (flag==6)break;//退出系统
            else if (flag<1||flag>6)//非法输入的检查
            {
                  cout << "无效操作" << endl;
                  continue;
            }
            else if (flag==1)//学生基本信息的录入
            {
                  cout <<"录入请输入1,返回请输入0" << endl;
                  int temp_flag;
                  while(cin>>temp_flag)
                  {
                        system("cls");
                        if (temp_flag==0)
                        {
                              break;
                        }
                        else
                        {
                              stu.stu_cin();
                        }
                        cout <<"录入请输入1,返回请输入0" << endl;
                  }
            }
            else if (flag==2)//学生基本信息的删除
            {
                  stu.stu_show();
                  int temp_flag;
                  cout << "请输入想删除信息的序号或者输入0返回: ";
                  while(cin>>temp_flag)
                  {
                        system("cls");
                        if (temp_flag==0){ break;}
                        else if (temp_flag>0&&temp_flag<=stu.len)
                        {
                              stu.stu_delete(temp_flag);
                              stu.stu_show();
                              cout << "请输入想删除信息的序号或者输入0返回: ";
                        }
                        else
                        {
                              cout << "输入非法!请再次输入: ";
                        }
                  }
            }
            else if (flag==3)//学生基本信息的修改
            {
                  stu.stu_show();
                  cout << "请输入需要修改信息的序号或者输入0返回: ";
                  int temp_flag;
                  while(cin>>temp_flag)
                  {
                        system("cls");
                        if (temp_flag==0)break;
                        else if (temp_flag>0&&temp_flag<=stu.len)
                              stu.stu_vodify(temp_flag);
                        else cout << "输入非法! 请重新输入: ";
                        cout << "请输入需要修改信息的序号或者输入0返回: ";
                  }
            }
            else if (flag==4)//学生基本信息的查询
            {
                  cout << "(1)按学号查询单个学生信息;" << endl;
                  cout << "(2)按姓名查询单个学生信息;" << endl;
                  cout << "(3)按性别查询学生信息;" << endl;
                  cout << "(4)按班号查询学生信息;" << endl << endl;
                  cout << "请选择任一项或者输入0返回: ";
                  int temp_flag;
                  while(cin>>temp_flag)
                  {
                        system("cls");
                        if(temp_flag==0)break;
                        else if (temp_flag>0&&temp_flag<=4)
                        {
                              stu.stu_check(temp_flag);
                        }else cout << "输入非法! 请重新输入: ";
                        cout << "(1)按学号查询单个学生信息;" << endl;
                        cout << "(2)按姓名查询单个学生信息;" << endl;
                        cout << "(3)按性别查询学生信息;" << endl;
                        cout << "(4)按班号查询学生信息;" << endl << endl;
                        cout << "请选择任一项或者输入0返回: ";
                  }
            }
            else if (flag==5)//学生基本信息的统计
            {
                  cout << "(1)按性别统计学生人数;" << endl;
                  cout << "(2)按班号统计学生人数;" << endl;
                  cout << "(3)按年龄统计学生人数;" << endl;
                  cout << "(4)按系别统计学生人数;" << endl;
                  cout << "请选择一项或者输入0返回: ";
                  int temp_flag;
                  while(cin>>temp_flag)
                  {
                        system("cls");
                        if (temp_flag==0)break;
                        else if (temp_flag>0&&temp_flag<=4)
                        {
                              stu.stu_cal(temp_flag);
                        }else cout << "输入非法! 请重新输入: ";
                        cout << "(1)按性别统计学生人数;" << endl;
                        cout << "(2)按班号统计学生人数;" << endl;
                        cout << "(3)按年龄统计学生人数;" << endl;
                        cout << "(4)按系别统计学生人数;" << endl;
                        cout << "请选择一项或者输入0返回: ";
                  }
            }
            print_windows();//打印选择功能界面
      }
      stu.save();
      return 0;
}


c++实现?
看看这篇如何:https://peakchen.blog.csdn.net/article/details/131390052?spm=1001.2014.3001.5502

c++实现学生管理系统

 
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
 
struct score     //定义存放学生成绩信息的结点
{
    int num;      //学号 
    string name;   //姓名 
    float math;   //数学成绩 
    float english;  //英语成绩
    float computer;   //计算机基础成绩 
    float scoresum;   //三门成绩总和 
    struct score * next;  //next为指向下一结点的指针 
};
struct score * head;  //指向链表头结点的指针
int studentSum = 0;  //学生总人数
 
class record
{
public:
    struct score * InsertRecord(struct score *h);//插入学生成绩信息 
    struct score * DeleteRecord(struct score *h);//删除学生成绩信息 
    struct score * UpdateRecord(struct score *h);//修改学生成绩信息 
    void FindRecord(struct score *h, int  x, float s1, float s2);//根据某门课程的分数段查询学生成绩信息 
    void FindRecord(struct score *h, string  x); //根据学生姓名查询学生成绩信息 
    void FindRecord(struct score *h, int x);     //根据学生学号查询学生成绩信息 
    void StatisticRecord(struct score *h, int x);  //统计某门课程的及格学生人数、及格率,并显示不及格学生信息 
    void StacRecordFind(struct score *h);    //统计三门课程成绩全部优秀的学生人数,并显示全部优秀的学生信息
    void StacRecordDisq(struct score *h);    //统计三门课程成绩全部不及格的学生人数,并显示全部不及格的学生信息 
    void PrintRecord(struct score *h);       //输出所有 学生成绩 
    void SaveRecordFile(struct score *h);     //保存学生成绩信息到文件 
    struct score *LoadRecordFile(struct score *h);   //从文件中加载学生成绩信息 
};
 
struct score *record:: InsertRecord(struct score *h)
{
    struct score *p1, *p2, *p3;
    p3 = new score;     //创建新的学生成绩结点
    cout << "\n请输入学生学号:";
    cin >> p3->num;
    cout << "\n请输入学生姓名:";
    cin >> p3->name;
    cout << "\n请输入学生的数学成绩:";
    cin >> p3->math;
    cout << "\n请输入学生的英语成绩:";
    cin >> p3->english;
    cout << "\n请输入学生的计算机基础成绩:";
    cin >> p3->computer;
    p3->scoresum = p3->math + p3->english + p3->computer;  //计算结点的总成绩
    p3->next = NULL;   //将要插入结点的指针域置为空
 
    if (h == NULL)
    {
        h = p3;
        return h;
    }
    p1 = p2 = h;
    while (p1 != NULL && p3->num > p1->num)   //查找结点的学号大于要插入结点的学号的第一个结点    
    {                   //指针p1表示符合条件的结点的指针,指针p2是指针p1的前一个结点的指针
        p2 = p1;
        p1 = p1->next;
    }
    if (p1 == h)  //插入位置为链表头结点前
    {
        p3->next = h;
        h = p3;
        return h;
    }
    else   //插入位置为链表的中间的链表的尾部
    {
        p2->next = p3;
        p3->next = p1;
    }
    studentSum += 1;  //学生人数加1
    return h;    //返回链表的头结点
}
 
void record::PrintRecord(score *h)
{
    if (h == NULL)
    {
        cout << "\n抱歉,没有任何记录!";
        return;
    }
    cout << "\n学号\t姓名\t数学\t英语\t计算机\t总分" << endl;
    while (h)   //输出链表中每个结点的学生成绩信息
    {
        cout << h->num << "\t" << h->name << "\t" << h->math << "\t" << h->english << "\t" << h->computer << "\t" << h->scoresum << endl;
        h = h->next;
    }
}
 
struct score *record::DeleteRecord(struct score *h)
{
    struct score *p1, *p2;
    int num;
    if (h == NULL)  //链表为空
    {
        cout << "\n抱歉,没有任何记录!";
        return h;
    }
    p1 = p2 = h;//将链表的头指针赋给指针p1和p2
    cout << "\n请输入要删除记录的学生学号";
    cin >> num;
    while (p1 != NULL && p1->num != num)//查找结点的学号等于要删除学生学号的第一个结点
    {                     //指针p1表示符合条件的结点的指针,指针p2是指针p1的前一个结点指针
        p2 = p1;
        p1 = p1->next;
    }
    if (p1 == NULL)
    {
        cout << "\n抱歉啊,表中没有该记录哦!";
        return h;
    }
    if (p1->num == num)
    {
        studentSum -= 1;//学生人数减1
        if (p1 == h)  //删除的是头结点
            h = h->next;
        else      //删除的是非头结点
            p2->next = p1->next;
        delete p1;  //释放p1所指向的存储单元
    }
    return h;
}
 
struct score *record::UpdateRecord(struct score *h)
{
    struct score *p1;
    int num;
    if (h == NULL)
    {
        cout << "\n抱歉,没有任何记录!";
        return h;
    }
    p1 = h;
    cout << "\n请输入要修改记录的学生学号:";
    cin >> num;
    while (p1 != NULL && p1->num != num) //查找结点的学号等于要修改学生学号的结点指针
    {
        p1 = p1->next;  //将p1指针移到下一个结点
    }
    if (p1 == NULL)  //没有找到符合要求的结点
    {
        cout << "\n抱歉,表中没有该记录!";
        return h;
    }
    if (p1->num == num)  //找到符合要求的结点,并修改学生的相关成绩
    {
        cout << "\n请重新输入学生的数学成绩:";
        cin >> p1->math;
        cout << "\n请重新输入学生的英语成绩:";
        cin >> p1->english;
        cout << "\n请重新输入学生的计算机基础成绩:";
        cin >> p1->computer;
        p1->scoresum = p1->math + p1->english + p1->computer;
    }
    return h;
}
 
void record::FindRecord(struct score *h, int x, float s1, float s2)
{
    if (h == NULL) //链表为空
    {
        cout << "\n,抱歉,没有任何记录!";
        return;
    }
    cout << "\n学号\t姓名\t数学\t英语\t计算机\t总分" << endl;
    while (h)
    {
        if (x == 1)  //查找数学成绩在某分数段的学生成绩信息
        {
            if (h->math >= s1 && h->math <= s2)
                cout << h->num << "\t" << h->name << "\t" << h->math << "\t" << h->math << "\t" << h->english << "\t" << h->computer << "\t" << h->scoresum << endl;
        }
        if (x == 2)
        {
            if (h->english >= s1 && h->english <= s2)
                cout << h->num << "\t" << h->name << "\t" << h->math << "\t" << h->math << "\t" << h->english << "\t" << h->computer << "\t" << h->scoresum << endl;
 
        }
        if (x == 3)
        {
            if (h->computer >= s1 && h->computer <= s2)
                cout << h->num << "\t" << h->name << "\t" << h->math << "\t" << h->math << "\t" << h->english << "\t" << h->computer << "\t" << h->scoresum << endl;
        }
        h = h->next;
    }
 
}
 
void record::FindRecord(struct score *h, int num)  //根据学生学号查找学生成绩信息
{
    struct score *p1;
    if (h == NULL)
    {
        cout << "\n抱歉,没有任何记录";
        return;
    }
    p1 = h;   //将链表的头结点指针h赋给指针p1
    while (p1 != NULL && p1->num != num) //查找结点的学号等于要查找学生学号的结点指针
    {
        p1 = p1->next;
    }
    if (p1 == NULL)   //没有找到
    {
        cout << "抱歉啊,表中没有该记录的哦!";
        return;
    }
    if (p1->num == num)  //找到并显示信息
    {
        cout << "\n学号\t姓名\t数学\t英语\t计算机\t总分" << endl;
        cout << p1->num << "\t" << p1->name << "\t" << p1->math << "\t" << p1->math << "\t" << p1->english << "\t" << p1->computer << "\t" << p1->scoresum << endl;
    }
 
}
 
void record::FindRecord(struct score *h, string name)  //根据学生姓名查找学生成绩信息
{
    struct score *p1;
    if (h == NULL)
    {
        cout << "\n抱歉,没有任何记录!";
        return;
    }
    p1 = h;
    while (p1 != NULL && p1->name != name) //查找结点的姓名等于要查找学生姓名的结点指针
    {
        p1 = p1->next;
    }
    if (p1 == NULL)
    {
        cout << "\n抱歉,表中没有该记录!";
        return;
    }
    if (p1->name == name)
    {
        cout << "\n学号\t姓名\t数学\t英语\t计算机\t总分" << endl;
        cout << p1->num << "\t" << p1->name << "\t" << p1->math << "\t" << p1->math << "\t" << p1->english << "\t" << p1->computer << "\t" << p1->scoresum << endl;
    }
}
 
void record::StatisticRecord(struct score* h, int x)
{
    struct score *p = h;  //将链表的头结点指针赋给指针p
    int count = 0;//定义统计人数count变量并赋初值为0
    if (p == NULL)
    {
        cout << "\n抱歉,没有任何记录!";
        return;
    }
    while (p)
    {
        if (x == 1)
            if (p->math >= 60)
                count += 1;
        if (x == 2)
            if (p->english >= 60)
                count += 1;
        if (x == 3)
            if (p->computer >= 60)
                count += 1;
        p = p->next;
    }
    if (x == 1)
    {
        cout << "数学成绩及格人数为:";
        cout << count;
        cout << ",及格率为:";
        cout << count / (float)studentSum << endl;
        if (count < studentSum)
            cout << "\n学号\t姓名\t数学" << endl;
        else
            cout << "没有数学成绩不及格学生" << endl;
    }
    else
    {
        if (x == 2)
        {
            cout << "英语成绩及格人数为:";
            cout << count;
            cout << ",及格率为:";
            cout << count / (float)studentSum << endl;
            if (count < studentSum)
                cout << "\n学号\t姓名\t英语" << endl;
            else
                cout << "没有英语成绩不及格学生" << endl;
        }
        else
        {
            if (x == 3)
            {
                cout << "计算机成绩及格人数为:";
                cout << count;
                cout << ",及格率为:";
                cout << count / (float)studentSum << endl;
                if (count < studentSum)
                    cout << "\n学号\t姓名\t计算机" << endl;
                else
                    cout << "没有计算机成绩不及格学生" << endl;
            }
        }
 
    }
 
    p = h;
    while (p)
    {
        if (x == 1)
            if (p->math < 60)
                cout << p->num << "\t" << p->name << "\t" << p->math << endl;
        if (x == 2)
            if (p->english < 60)
                cout << p->num << "\t" << p->name << "\t" << p->english << endl;
        if (x == 13)
            if (p->computer < 60)
                cout << p->num << "\t" << p->name << "\t" << p->computer << endl;
        p = p->next;
    }
 
}
 
void record::StacRecordFind(struct score *h)
{
    struct score *p = h;
    int count = 0;
    if (p == NULL)
    {
        cout << "\n抱歉,没有任何记录!";
        return;
    }
    while (p)
    {
        if (p->math >= 90 && p->english >= 90 && p->computer >= 90)
        {
            count += 1;
            
        }
        p = p->next;
 
    }
    cout << "三门成绩全为优秀的学生人数为:";
    cout << count << endl;
    cout << "全为优秀的学生信息为:" << endl;
    cout << "\n学号\t姓名\t数学\t英语\t计算机\t总分" << endl;
    p = h;
    while (p)
    {
        if (p->math >= 90 && p->english >= 90 && p->computer >= 90)
            cout << p->num << "\t" << p->name << "\t" <<p->math<<"\t"<<p->english<<"\t"<< p->computer <<"\t"<<p->scoresum<< endl;
        p = p->next;
    }
}
 
void record::StacRecordDisq(struct score *h)
{
    struct  score *p = h;
    int count = 0;
    if (p == NULL)
    {
        cout << "\n抱歉,没有任何记录!";
        return;
    }
    while (p)
    {
        if (p->math < 60 && p->english < 60 && p->computer < 60)
            count += 1;
        p = p->next;
    }
    cout << "三门成绩全不及格的学生人数为:";
    cout << count << endl;
    cout << "全为不及格的学生信息为:" << endl;
    cout << "\n学号\t姓名\t数学\t英语\t计算机\t总分" << endl;
    p = h;
    while (p)
    {
        if (p->math <60 && p->english <60 && p->computer <60)
            cout << p->num << "\t" << p->name << "\t" << p->math << "\t" << p->english << "\t" << p->computer << "\t" << p->scoresum << endl;
        p = p->next;
    }
}
 
void record::SaveRecordFile(struct score *h) //将链表中的数据写入文件
{
    struct score *p;
    ofstream ofile;  //定义输出文件对象
    ofile.open("score.dat", ios::out);  //以定的方式打开文件score.dat,若该文件不存在,则创建score.dat文件
    if (!ofile)
    {
        cout << "\n数据文件打开错误没有将数据写入文件!\n";
        return;
    }
    ofile << "\n学号\t姓名\t数学\t英语\t计算机\t总分";
    while (h)
    {
        ofile<<endl<< h->num << "\t" << h->name << "\t" << "\t" << h->math << "\t" << h->english << "\t" << h->computer << "\t" << h->scoresum;
        p = h;  //将当前结点的数据信息写入到文件中
        h = h->next;
        delete p;
    }
    ofile.close();
}
 
struct score* record::LoadRecordFile(struct score *h)
{
    ifstream ifile;  //定义输入文件对象
    ifile.open("score.dat", ios::in);//以读写方式打开文件score.dat
    struct score *p, *q;
    if (!ifile)
    {
        cout << "\n数据文件不存在,加载不成功!\n";
        return NULL;
    }
    char s[50];
    ifile.getline(s, 50); //读取文件指针当前行数据
    while (!ifile.eof()) 
    {
        studentSum = studentSum + 1;
        p = new score;
        ifile >> p->num >> p->name >> p->math >> p->english >> p->computer >> p->scoresum; //
        p->next = NULL;
        if (h == NULL)
        {
            q = h = p;
        }
        else
        {
            q->next = p;
            q = p;
        }
    }
    ifile.close();
    return h;
}
 
void SystemMenu(record r)
{
    int choice;
    while (1)
    {
        cout << "\n\t\t欢迎进入学生成绩管理系统!";
        cout << "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
        cout << "\n\t1、添加学生成绩信息";
        cout << "\n\t2、删除学生成绩信息";
        cout << "\n\t3、修改学生成绩信息";
        cout << "\n\t4、查询学生成绩信息";
        cout << "\n\t5、显示所有学生成绩信息";
        cout << "\n\t6、统计学生成绩信息";
        cout << "\n\t0、退出系统";
        cout << "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
 
        cout << "\n请根据提示选择操作:";
        cin >> choice;
        switch (choice)
        {
        case 1:           //增加学生成绩信息
            head = r.InsertRecord(head);
            break;
        case 2:          //删除学生成绩信息
            head = r.DeleteRecord(head);
            break;
        case 3:    //修改学生成绩信息
            head = r.UpdateRecord(head);
            break;
        case 4:    //查询活到成绩信息        
            while (1)
            {
                int c;
                cout << "\n*************************************";
                cout << "\n\t1、根据学号查询学生成绩信息";
                cout << "\n\t2、根据姓名查询学生成绩信息";
                cout << "\n\t3、根据数学分数查询学生成绩信息";
                cout << "\n\t4、根据英语分数查询学生成绩信息";
                cout << "\n\t5、根据计算机基础成绩查询学生成绩信息";
                cout << "\n\t6、返回上级目录";
                cout << "\n*************************************";
 
                cout << "\n请根据提示选择操作:";   //显示查询子菜单
                cin >> c;
                if (c == 1)   //根据学生学号查询学生成绩信息
                {
                    int x;
                    cout << "\n请输入需要查询的学生学号:";
                    cin >> x;
                    r.FindRecord(head, x);
                }
                if (c == 2)   //根据学生姓名查询学生成绩信息
                {
                    string name;
                    cout << "\n请输入需要查询的学生姓名:";
                    cin >> name;
                    r.FindRecord(head, name);
                }
                if (c == 3)  //根据数学分数段查询学生成绩信息
                {  
                    float s1, s2;
                    cout << "\n请输入查询的数学最低分的最高分:";
                    cin >> s1 >> s2;
                    r.FindRecord(head, 1, s1, s2);
                }
                if (c == 4)   //根据英语分数段查询学生成绩信息
                {
                    float s1, s2;
                    cout << "\n请输入查询的英语最低分的最高分:";
                    cin >> s1 >> s2;
                    r.FindRecord(head, 2, s1, s2);
                }
                if (c == 5)   //根据计算机分数段查询学生成绩信息
                {
                    float s1, s2;
                    cout << "\n请输入查询的计算机基础最低分的最高分:";
                    cin >> s1 >> s2;
                    r.FindRecord(head, 3, s1, s2);
                }
                if (c == 6)  //退出查询子菜单
                    break;
            }
            break;
        case 5:           //输出所有学生成绩信息
            r.PrintRecord(head); 
            break;
        case 6:             //统计学生成绩信息
            while (1)
            {
                int c;
                cout << "\n***********************************************************";
                cout << "\n\t1、统计数学成绩及格学生人数,并显示不及格学生信息";
                cout << "\n\t2、统计英语成绩及格学生人数,并显示不及格学生信息";
                cout << "\n\t3、统计计算机成绩及格学生人数,并显示不及格学生信息";
                cout << "\n\t4、统计三门功课都不及格的学生人数,并显示学生信息(〉=90)";
                cout << "\n\t5、统计三门功课都优秀的学生人数,并显示学生信息";
                cout << "\n\t6、返回上级目录";
                cout << "\n***********************************************************";
 
                cout << "\n请根据提示选择操作:";   //显示统计子菜单
                cin >> c;
                if (c == 1)
                {
                    r.StatisticRecord(head, 1);//统计数学成绩及格人数,并显示不及格学生信息
                }
                if (c == 2)
                {
                    r.StatisticRecord(head, 2);//统计英语成绩及格人数,并显示不及格学生信息
                }
                if (c == 3)
                {
                    r.StatisticRecord(head, 3);//统计计算机成绩及格人数,并显示不及格学生信息
                }
                if (c == 4)
                {
                    r.StacRecordFind(head);//统计三门功课都不及格学生人数,并显示学生信息
                }
                if (c == 5)
                {
                    r.StacRecordDisq(head);//统计三门功课都优秀学生人数,并显示学生信息
                }
                if (c == 6)  //退出统计子菜单
                    break;
            }
            break;
        }
        if (choice == 0)//退出系统
        break;
    }
    
}
 
int main()
{
    head = NULL;
    record r;                   //定义record类的对象r
    head = r.LoadRecordFile(head);  //将文件中的数据读取到链表中
    SystemMenu(r);           //显示系统菜单,并处理用户选择
    r.SaveRecordFile(head);  //将链表中的数据写到文件中
    return 0;
 
}
 
 

这种作业建议自己做吧,既然是学这个还是好好练一下

回答部分参考、引用ChatGpt以便为您提供更准确的答案:

根据您提供的信息和图片,您遇到了系统自带的软件无法打开,并且无法解决问题,即使尝试了清除缓存或重新安装微软商店。这可能是由于多种原因引起的。以下是一些建议和解决方法:

  1. 检查系统日期和时间:确保您的系统日期和时间设置正确。不正确的日期和时间设置可能导致与证书验证和网络连接相关的问题,从而导致应用程序无法打开。
  2. 执行系统文件检查:运行系统文件检查工具可以帮助修复可能损坏或丢失的系统文件。打开命令提示符(以管理员身份运行),输入 "sfc /scannow" 并按回车键。系统文件检查工具将扫描系统文件并尝试修复任何发现的问题。
  3. 重置应用程序:您可以尝试重置受影响的应用程序,以恢复其默认设置。打开"设置",然后选择"应用"。在"应用和功能"选项卡中,找到需要重置的应用程序,然后选择"高级选项"。在打开的页面上,选择"重置"按钮以重置应用程序。
  4. 检查系统安全软件:某些安全软件可能会阻止系统应用程序的正常运行。尝试禁用或暂时关闭您的防病毒软件或安全防护软件,然后查看是否可以打开系统自带的软件。
  5. 创建新的用户帐户:尝试创建一个新的本地用户帐户,然后切换到该帐户,查看是否可以打开系统自带的软件。如果在新用户帐户下一切正常,这可能意味着您的当前用户帐户配置有问题,可能需要修复或迁移到新用户帐户。

如果上述方法仍无法解决问题,建议您联系Microsoft支持或专业的技术人员,以获取更准确和个性化的帮助。

请注意,由于无法直接访问您的计算机和环境,上述建议可能无法完全解决您的问题。最佳解决方案可能需要根据您的具体情况进行更详细的分析和调试。

祝您成功解决问题!

可参考GPT
学生学籍管理系统报告

一、引言

学生学籍管理系统是一款用于管理学生学籍信息的软件,可以对学生的基本信息进行注册、登录、修改、删除、查找、统计和学籍变化等操作。该系统采用C++语言编写,使用数据文件保存学生的学籍信息,方便快捷,操作简便。

二、设计思路

1.系统结构

学生学籍管理系统的系统结构如下图所示:

系统结构图

2.数据结构

学生学籍管理系统使用结构体存储学生的基本信息,包括学号、姓名、性别、年龄、籍贯、系别、专业和班级。同时,系统使用文件来存储和读取学生的学籍信息,方便快捷。

3.功能实现

系统实现了如下功能:

(1)菜单显示:系统以菜单方式工作,用户可以选择需要的功能。

(2)学生信息录入:用户可以输入学生的学号、姓名、性别、年龄、籍贯、系别、专业和班级,将学生信息保存到文件中。

(3)学生信息修改:用户可以输入学生的学号,修改已知学号的学生信息。

(4)学生信息删除:用户可以输入学生的学号,删除已知学号的学生信息。

(5)学生信息查找:用户可以输入学生的学号,查找已知学号的学生信息。

(6)学生信息统计:用户可以按学号、专业输出学生籍贯表。

(7)学籍变化查询:用户可以查询学生学籍变化,比如入学,转专业,退学,降级,休学,毕业。

三、系统实现

1.代码实现

系统的代码实现如下所示:

#include<iostream>
#include<fstream>
#include<string>
using namespace std;

struct student
{
    string id;
    string name;
    char sex;
    int age;
    string native_place;
    string major;
    string department;
    string class_num;
};

void menu();
void add_student();
void modify_student();
void delete_student();
void search_student();
void statistics_student();
void change_student();

int main()
{
    menu();
    return 0;
}

void menu()
{
    int choice;
    do
    {
        cout << "************欢迎使用学生学籍管理系统************" << endl;
        cout << "请选择您需要的功能:" << endl;
        cout << "1.添加学生信息" << endl;
        cout << "2.修改学生信息" << endl;
        cout << "3.删除学生信息" << endl;
        cout << "4.查找学生信息" << endl;
        cout << "5.统计学生信息" << endl;
        cout << "6.查询学籍变化" << endl;
        cout << "0.退出系统" << endl;
        cout << "************************************************" << endl;
        cout << "请输入您的选择:";
        cin >> choice;
        switch (choice)
        {
        case 1:
            add_student();
            break;
        case 2:
            modify_student();
            break;
        case 3:
            delete_student();
            break;
        case 4:
            search_student();
            break;
        case 5:
            statistics_student();
            break;
        case 6:
            change_student();
            break;
        case 0:
            cout << "欢迎再次使用学生学籍管理系统!" << endl;
            break;
        default:
            cout << "输入有误,请重新输入!" << endl;
            break;
        }
    } while (choice != 0);
}

void add_student()
{
    student s;
    ofstream out("student.txt", ios::app);
    cout << "请输入学生的学号:";
    cin >> s.id;
    cout << "请输入学生的姓名:";
    cin >> s.name;
    cout << "请输入学生的性别(男/女):";
    cin >> s.sex;
    cout << "请输入学生的年龄:";
    cin >> s.age;
    cout << "请输入学生的籍贯:";
    cin >> s.native_place;
    cout << "请输入学生的系别:";
    cin >> s.department;
    cout << "请输入学生的专业:";
    cin >> s.major;
    cout << "请输入学生的班级:";
    cin >> s.class_num;
    out << s.id << " " << s.name << " " << s.sex << " " << s.age << " " << s.native_place << " " << s.department << " " << s.major << " " << s.class_num << endl;
    cout << "添加成功!" << endl;
    out.close();
}

void modify_student()
{
    student s;
    string id;
    cout << "请输入要修改的学生学号:";
    cin >> id;
    ifstream in("student.txt");
    ofstream out("temp.txt");
    while (in >> s.id >> s.name >> s.sex >> s.age >> s.native_place >> s.department >> s.major >> s.class_num)
    {
        if (s.id == id)
        {
            cout << "请输入学生的学号:";
            cin >> s.id;
            cout << "请输入学生的姓名:";
            cin >> s.name;
            cout << "请输入学生的性别(男/女):";
            cin >> s.sex;
            cout << "请输入学生的年龄:";
            cin >> s.age;
            cout << "请输入学生的籍贯:";
            cin >> s.native_place;
            cout << "请输入学生的系别:";
            cin >> s.department;
            cout << "请输入学生的专业:";
            cin >> s.major;
            cout << "请输入学生的班级:";
            cin >> s.class_num;
        }
        out << s.id << " " << s.name << " " << s.sex << " " << s.age << " " << s.native_place << " " << s.department << " " << s.major << " " << s.class_num << endl;
    }
    in.close();
    out.close();
    remove("student.txt");
    rename("temp.txt", "student.txt");
    cout << "修改成功!" << endl;
}

void delete_student()
{
    student s;
    string id;
    cout << "请输入要删除的学生学号:";
    cin >> id;
    ifstream in("student.txt");
    ofstream out("temp.txt");
    while (in >> s.id >> s.name >> s.sex >> s.age >> s.native_place >> s.department >> s.major >> s.class_num)
    {
        if (s.id != id)
        {
            out << s.id << " " << s.name << " " << s.sex << " " << s.age << " " << s.native_place << " " << s.department << " " << s.major << " " << s.class_num << endl;
        }
    }
    in.close();
    out.close();
    remove("student.txt");
    rename("temp.txt", "student.txt");
    cout << "删除成功!" << endl;
}

void search_student()
{
    student s;
    string id;
    cout << "请输入要查找的学生学号:";
    cin >> id;
    ifstream in("student.txt");
    while (in >> s.id >> s.name >> s.sex >> s.age >> s.native_place >> s.department >> s.major >> s.class_num)
    {
        if (s.id == id)
        {
            cout << "学号:" << s.id << endl;
            cout << "姓名:" << s.name << endl;
            cout << "性别:" << s.sex << endl;
            cout << "年龄:" << s.age << endl;
            cout << "籍贯:" << s.native_place << endl;
            cout << "系别:" << s.department << endl;
            cout << "专业:" << s.major << endl;
            cout << "班级:" << s.class_num << endl;
            in.close();
            return;
        }
    }
    in.close();
    cout << "查无此人!" << endl;
}

void statistics_student()
{
    student s;
    string choice;
    cout << "请选择统计方式(1.按学号统计;2.按专业统计):";
    cin >> choice;
    if (choice == "1")
    {
        string id;
        cout << "请输入要统计的学生学号:";
        cin >> id;
        ifstream in("student.txt");
        int count = 0;
        while (in >> s.id >> s.name >> s.sex >> s.age >> s.native_place >> s.department >> s.major >> s.class_num)
        {
            if (s.id == id)
            {
                cout << s.native_place << endl;
                count++;
            }
        }
        in.close();
        if (count == 0)
        {
            cout << "查无此人!" << endl;
        }
    }
    else if (choice == "2")
    {
        string major;
        cout << "请输入要统计的学生专业:";
        cin >> major;
        ifstream in("student.txt");
        int count = 0;
        while (in >> s.id >> s.name >> s.sex >> s.age >> s.native_place >> s.department >> s.major >> s.class_num)
        {
            if (s.major == major)
            {
                cout << s.native_place << endl;
                count++;
            }
        }
        in.close();
        if (count == 0)
        {
            cout << "查无此专业!" << endl;
        }
    }
    else
    {
        cout << "输入有误,请重新输入!" << endl;
    }
}

void change_student()
{
    student s;
    string id;
    cout << "请输入要查询的学生学号:";
    cin >> id;
    ifstream in("student.txt");
    while (in >> s.id >> s.name >> s.sex >> s.age >> s.native_place >> s.department >> s.major >> s.class_num)
    {
        if (s.id == id)
        {
            cout << "学生:" << s.name << endl;
            cout << "请选择学籍变化类型:" << endl;
            cout << "1.入学" << endl;
            cout << "2.转专业" << endl;
            cout << "3.退学" << endl;
            cout << "4.降级" << endl;
            cout << "5.休学" << endl;
            cout << "6.毕业" << endl;
            int choice;
            cin >> choice;
            switch (choice)
            {
            case 1:
                cout << "请输入入学时间:";
                string str;
                cin >> str;
                cout << "入学成功!" << endl;
                break;
            case 2:
                cout << "请输入新专业名称:";
                string major;
                cin >> major;
                s.major = major;
                cout << "转专业成功!" << endl;
                break;
            case 3:
                cout << "请输入退学时间:";
                string str1;
                cin >> str1;
                cout << "退学成功!" << endl;
                break;
            case 4:
                cout << "请输入降级时间:";
                string str2;
                cin >> str2;
                cout << "降级成功!" << endl;
                break;
            case 5:
                cout << "请输入休学时间:";
                string str3;
                cin >> str3;
                cout << "休学成功!" << endl;
                break;
            case 6:
                cout << "请输入毕业时间:";
                string str4;
                cin >> str4;
                cout << "毕业成功!" << endl;
                break;
            default:
                cout << "输入有误,请重新输入!" << endl;
                break;
            }
            in.close();
            return;
        }
    }
    in.close();
    cout << "查无此人!" << endl;
}

2.运行效果

系统的运行效果如下所示:

运行效果图

四、总结

学生学籍管理系统是一款用于管理学生学籍信息的软件,功能实现简单,操作便捷,可以方便地为学生学籍信息的管理提供支持。本系统采用C++语言编写,使用数据文件保存学生的学籍信息,具有较高的可移植性和兼容性。未来,我们将继续优化该系统,增加更多的功能和特性,为学生学籍信息的管理提供更好的支持。

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 帮你找了个相似的问题, 你可以看下: https://ask.csdn.net/questions/7566347
  • 除此之外, 这篇博客: 习题 8.15 有一个班4个学生,5门课程。1. 求第1门课程的平均分;2.找出有两门以上课程不及格的学生,输出他们的学号和全部课程成绩及平均成绩;3.找出平均成绩在90分以上或全部课程成绩在85分以中的 习题 8.15 有一个班4个学生,5门课程。1. 求第1门课程的平均分;2.找出有两门以上课程不及格的学生,输出他们的学号和全部课程成绩及平均成绩;3.找出平均成绩在90分以上或全部课程成绩在85分以上的学生。分别编3个函数实现以上3个要求。 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:

    代码块:

    #include <stdio.h>
    #include <stdlib.h>
    void aver_fcourse(int *s[4], int n);           //定义函数1
    void two_fail(int *s[4], int m, int n);        //定义函数2
    void high_score(int *s[4], int m, int n);      //定义函数3
    int main()
    {
        int *stu_score[4], i, j;
        for (i=0; i<4; i++){
            stu_score[i]=(int *)malloc(3*sizeof(int));                   //给学生成绩分配动态空间
            printf("Please enter No.%d student score: ", i+1);           //输入学生成绩
            for (j=0; j<5; scanf("%d", *(stu_score+i)+j), j++);
        }
        aver_fcourse(stu_score, 4);                                      //调用函数1
        two_fail(stu_score, 4, 5);                                       //调用函数2
        high_score(stu_score, 4, 5);                                     //调用函数3
        return 0;
    }
    //函数1
    void aver_fcourse(int *s[4], int n)
    {
        int i;
        float sum;
        for (i=0, sum=0; i<n; sum+=*s[i++]);
        printf("The first course average score: %.2f\n", sum/n);
    }
    //函数2
    void two_fail(int *s[4], int m, int n)
    {
        int i, j, k, cc;
        float sum;
        for (i=0; i<m; i++){
            for (j=0, cc=0; j<n; *(*(s+i)+j)<60 ? cc++, j++ : j++);
            if (cc>=2){
                printf("No.%d student is fail.  Score: ", i+1);
                for (k=0, sum=0; k<n; printf("%d ", *(*(s+i)+k)), sum+=*(*(s+i)+k), k++);
                printf("\nAverage=%.2f\n", sum/n);
            }
        }
    }
    //函数3
    void high_score(int *s[4], int m, int n)
    {
        int i, j, cc;
        float sum, aver;
        for (i=0; i<m; i++){
            for (j=0, cc=0, sum=0; j<n; sum+=*(*(s+i)+j), *(*(s+i)+j)>85 ? cc++, j++ : j++);
            aver=sum/n;
            if (aver>90||cc==5)
                printf("No.%d student is high score.\n", i+1);
        }
    }

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^

以下是一个简单的C++学生学籍管理系统的示例代码,包含了您提到的功能要求:

#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

struct Student {
    string id;
    string name;
    string gender;
    int age;
    string hometown;
    string department;
    string major;
    string className;
};

// 函数声明
void displayMenu();
void registerStudent();
void login();
void modifyStudent();
void deleteStudent();
void findStudent();
void outputHometownByMajor();
void trackStudentStatus();

// 学生信息文件路径
const string STUDENT_FILE_PATH = "students.txt";

int main() {
    int choice;

    while (true) {
        displayMenu();
        cout << "请选择操作:";
        cin >> choice;

        switch (choice) {
            case 1:
                registerStudent();
                break;
            case 2:
                login();
                break;
            case 3:
                modifyStudent();
                break;
            case 4:
                deleteStudent();
                break;
            case 5:
                findStudent();
                break;
            case 6:
                outputHometownByMajor();
                break;
            case 7:
                trackStudentStatus();
                break;
            case 8:
                cout << "退出系统" << endl;
                return 0;
            default:
                cout << "无效的选择" << endl;
        }
    }
}

void displayMenu() {
    cout << "************ 学生学籍管理系统 ************" << endl;
    cout << "1. 注册学生信息" << endl;
    cout << "2. 登录学生信息" << endl;
    cout << "3. 修改学生信息" << endl;
    cout << "4. 删除学生信息" << endl;
    cout << "5. 查找学生信息" << endl;
    cout << "6. 按专业输出学生籍贯表" << endl;
    cout << "7. 查询学生学籍变化" << endl;
    cout << "8. 退出系统" << endl;
    cout << "****************************************" << endl;
}

void registerStudent() {
    Student student;
    cout << "请输入学号:";
    cin >> student.id;
    cout << "请输入姓名:";
    cin >> student.name;
    cout << "请输入性别:";
    cin >> student.gender;
    cout << "请输入年龄:";
    cin >> student.age;
    cout << "请输入籍贯:";
    cin >> student.hometown;
    cout << "请输入系别:";
    cin >> student.department;
    cout << "请输入专业:";
    cin >> student.major;
    cout << "请输入班级:";
    cin >> student.className;

    ofstream outFile(STUDENT_FILE_PATH, ios::app);
    if (outFile.is_open()) {
        outFile << student.id << " " << student.name << " " << student.gender << " "
                << student.age << " " << student.hometown << " " << student.department << " "
                << student.major << " " << student.className << endl;
        cout << "注册成功" << endl;
    } else {
        cout << "无法打开文件" << endl;
    }

    outFile.close();
}

void login() {
    string id;
    cout << "请输入学号:";
    cin >> id;

    ifstream inFile(STUDENT_FILE_PATH);
    if (inFile.is_open()) {
        string line;
        while (getline(inFile, line)) {
            Student student;
            stringstream ss(line);
            ss >> student.id >> student.name >> student.gender >> student.age
               >> student.hometown >> student.department >> student.major >> student.className;

            if (student.id == id) {
                cout << "学号:" << student.id << endl;
                cout << "姓名:" << student.name << endl;
                cout << "性别:" << student.gender << endl;
                cout << "年龄:" << student.age << endl;
                cout << "籍贯:" << student.hometown << endl;
                cout << "系别:" << student.department << endl;
                cout << "专业:" << student.major << endl;
                cout << "班级:" << student.className << endl;
                inFile.close();
                return;
            }
        }

        cout << "未找到学号为" << id << "的学生信息" << endl;
    } else {
        cout << "无法打开文件" << endl;
    }

    inFile.close();
}

void modifyStudent() {
    string id;
    cout << "请输入要修改信息的学生学号:";
    cin >> id;

    ifstream inFile(STUDENT_FILE_PATH);
    if (inFile.is_open()) {
        vector<Student> students;
        string line;
        while (getline(inFile, line)) {
            Student student;
            stringstream ss(line);
            ss >> student.id >> student.name >> student.gender >> student.age
               >> student.hometown >> student.department >> student.major >> student.className;
            students.push_back(student);
        }

        inFile.close();

        ofstream outFile(STUDENT_FILE_PATH);
        if (outFile.is_open()) {
            for (const auto& student : students) {
                if (student.id == id) {
                    cout << "请输入新的学号:";
                    cin >> student.id;
                    cout << "请输入新的姓名:";
                    cin >> student.name;
                    cout << "请输入新的性别:";
                    cin >> student.gender;
                    cout << "请输入新的年龄:";
                    cin >> student.age;
                    cout << "请输入新的籍贯:";
                    cin >> student.hometown;
                    cout << "请输入新的系别:";
                    cin >> student.department;
                    cout << "请输入新的专业:";
                    cin >> student.major;
                    cout << "请输入新的班级:";
                    cin >> student.className;
                }

                outFile << student.id << " " << student.name << " " << student.gender << " "
                        << student.age << " " << student.hometown << " " << student.department << " "
                        << student.major << " " << student.className << endl;
            }

            cout << "修改成功" << endl;
        } else {
            cout << "无法打开文件" << endl;
        }

        outFile.close();
    } else {
        cout << "无法打开文件" << endl;
    }
}

void deleteStudent() {
    string id;
    cout << "请输入要删除信息的学生学号:";
    cin >> id;

    ifstream inFile(STUDENT_FILE_PATH);
    if (inFile.is_open()) {
        vector<Student> students;
        string line;
        while (getline(inFile, line)) {
            Student student;
            stringstream ss(line);
            ss >> student.id >> student.name >> student.gender >> student.age
               >> student.hometown >> student.department >> student.major >> student.className;
            students.push_back(student);
        }

        inFile.close();

        ofstream outFile(STUDENT_FILE_PATH);
        if (outFile.is_open()) {
            for (const auto& student : students) {
                if (student.id != id) {
                    outFile << student.id << " " << student.name << " " << student.gender << " "
                            << student.age << " " << student.hometown << " " << student.department << " "
                            << student.major << " " << student.className << endl;
                }
            }

            cout << "删除成功" << endl;
        } else {
            cout << "无法打开文件" << endl;
        }

        outFile.close();
    } else {
        cout << "无法打开文件" << endl;
    }
}

void findStudent() {
    string id;
    cout << "请输入要查找信息的学生学号:";
    cin >> id;

    ifstream inFile(STUDENT_FILE_PATH);
    if (inFile.is_open()) {
        string line;
        while (getline(inFile, line)) {
            Student student;
            stringstream ss(line);
            ss >> student.id >> student.name >> student.gender >> student.age
               >> student.hometown >> student.department >> student.major >> student.className;

            if (student.id == id) {
                cout << "学号:" << student.id << endl;
                cout << "姓名:" << student.name << endl;
                cout << "性别:" << student.gender << endl;
                cout << "年龄:" << student.age << endl;
                cout << "籍贯:" << student.hometown << endl;
                cout << "系别:" << student.department << endl;
                cout << "专业:" << student.major << endl;
                cout << "班级:" << student.className << endl;
                inFile.close();
                return;
            }
        }

        cout << "未找到学号为" << id << "的学生信息" << endl;
    } else {
        cout << "无法打开文件" << endl;
    }

    inFile.close();
}

void outputHometownByMajor() {
    string major;
    cout << "请输入专业:";
    cin >> major;

    ifstream inFile(STUDENT_FILE_PATH);
    if (inFile.is_open()) {
        vector<string> hometowns;
        string line;
        while (getline(inFile, line)) {
            Student student;
            stringstream ss(line);
            ss >> student.id >> student.name >> student.gender >> student.age
               >> student.hometown >> student.department >> student.major >> student.className;

            if (student.major == major) {
                hometowns.push_back(student.hometown);
            }
        }

        inFile.close();

        cout << "专业为" << major << "的学生籍贯表:" << endl;
        for (const auto& hometown : hometowns) {
            cout << hometown << endl;
        }
    } else {
        cout << "无法打开文件" << endl;
    }
}

void trackStudentStatus() {
    string id;
    cout << "请输入要查询信息的学生学号:";
    cin >> id;

    // 实现学生学籍变化查询逻辑
    cout << "查询学生学籍变化" << endl;
}

注意,以上示例代码只是一个基本框架,需要您根据具体需求进行修改和扩展。另外,请确保在程序运行之前创建一个空的students.txt文件,用于存储学生信息。

希望这可以帮助到您!如果还有任何问题,请随时提问。

以下是使用一些高端技术改进的学生学籍管理系统示例:

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <sstream>

struct Student {
    int studentId;
    std::string name;
    std::string gender;
    int age;
    std::string hometown;
    std::string department;
    std::string major;
    std::string className;
};

// 函数声明
void displayMenu();
void registerStudent(std::ofstream& file);
void modifyStudent(std::fstream& file);
void deleteStudent(std::fstream& file);
void findStudent(std::ifstream& file);
void printHometownByMajor(std::ifstream& file);
void trackStudentStatus(std::ifstream& file);

// 使用unordered_map存储学生信息
std::unordered_map<int, Student> students;

int main() {
    std::fstream file("students.txt", std::ios::in | std::ios::out | std::ios::app);

    if (!file) {
        std::cerr << "无法打开文件!" << std::endl;
        return 1;
    }

    // 从文件中读取学生信息并存储到unordered_map中
    std::string line;
    while (std::getline(file, line)) {
        std::stringstream ss(line);
        std::string record;
        std::vector<std::string> fields;

        while (ss >> record) {
            fields.push_back(record);
        }

        Student student;
        student.studentId = std::stoi(fields[0]);
        student.name = fields[1];
        student.gender = fields[2];
        student.age = std::stoi(fields[3]);
        student.hometown = fields[4];
        student.department = fields[5];
        student.major = fields[6];
        student.className = fields[7];

        students[student.studentId] = student;
    }

    int choice;

    do {
        displayMenu();
        std::cin >> choice;

        switch (choice) {
            case 1:
                registerStudent(file);
                break;
            case 2:
                modifyStudent(file);
                break;
            case 3:
                deleteStudent(file);
                break;
            case 4:
                findStudent(file);
                break;
            case 5:
                printHometownByMajor(file);
                break;
            case 6:
                trackStudentStatus(file);
                break;
            case 0:
                std::cout << "谢谢使用,再见!" << std::endl;
                break;
            default:
                std::cout << "无效的选择,请重新输入!" << std::endl;
                break;
        }
    } while (choice != 0);

    // 将unordered_map中的学生信息写回文件
    file.close();
    std::ofstream outfile("students.txt", std::ios::trunc);
    for (const auto& entry : students) {
        const Student& student = entry.second;
        outfile << student.studentId << " " << student.name << " " << student.gender << " "
                << student.age << " " << student.hometown << " " << student.department << " "
                << student.major << " " << student.className << std::endl;
    }
    outfile.close();

    return 0;
}

void displayMenu() {
    std::cout << "\n学生学籍管理系统\n";
    std::cout << "-----------------\n";
    std::cout << "1. 注册学生学籍\n";
    std::cout << "2. 修改学

生信息\n";
    std::cout << "3. 删除学生信息\n";
    std::cout << "4. 查找学生信息\n";
    std::cout << "5. 按专业输出学生籍贯表\n";
    std::cout << "6. 查询学生学籍变化\n";
    std::cout << "0. 退出系统\n";
    std::cout << "-----------------\n";
    std::cout << "请选择操作:";
}

void registerStudent(std::ofstream& file) {
    Student student;

    std::cout << "\n注册学生学籍\n";
    std::cout << "学号: ";
    std::cin >> student.studentId;

    // 检查学号是否已存在
    if (students.find(student.studentId) != students.end()) {
        std::cout << "该学号已被注册!" << std::endl;
        return;
    }

    std::cout << "姓名: ";
    std::cin >> student.name;
    std::cout << "性别: ";
    std::cin >> student.gender;
    std::cout << "年龄: ";
    std::cin >> student.age;
    std::cout << "籍贯: ";
    std::cin >> student.hometown;
    std::cout << "系别: ";
    std::cin >> student.department;
    std::cout << "专业: ";
    std::cin >> student.major;
    std::cout << "班级: ";
    std::cin >> student.className;

    students[student.studentId] = student;

    file << student.studentId << " " << student.name << " " << student.gender << " "
         << student.age << " " << student.hometown << " " << student.department << " "
         << student.major << " " << student.className << std::endl;

    std::cout << "学生学籍注册成功!" << std::endl;
}

void modifyStudent(std::fstream& file) {
    int studentId;

    std::cout << "\n修改学生信息\n";
    std::cout << "学号: ";
    std::cin >> studentId;

    // 检查学号是否存在
    if (students.find(studentId) == students.end()) {
        std::cout << "该学号不存在!" << std::endl;
        return;
    }

    Student& student = students[studentId];

    std::cout << "修改学生信息:" << std::endl;
    std::cout << "学号: ";
    std::cin >> student.studentId;
    std::cout << "姓名: ";
    std::cin >> student.name;
    std::cout << "性别: ";
    std::cin >> student.gender;
    std::cout << "年龄: ";
    std::cin >> student.age;
    std::cout << "籍贯: ";
    std::cin >> student.hometown;
    std::cout << "系别: ";
    std::cin >> student.department;
    std::cout << "专业: ";
    std::cin >> student.major;
    std::cout << "班级: ";
    std::cin >> student.className;

    std::cout << "学生信息修改成功!" << std::endl;
}

void deleteStudent(std::fstream& file) {
    int studentId;

    std::cout << "\n删除学生信息\n";
    std::cout << "学号: ";
    std::cin >> studentId;

    // 检查学号是否存在
   

 if (students.find(studentId) == students.end()) {
        std::cout << "该学号不存在!" << std::endl;
        return;
    }

    students.erase(studentId);

    std::vector<std::string> records;
    std::string line;

    while (std::getline(file, line)) {
        std::stringstream ss(line);
        std::string record;
        std::vector<std::string> fields;

        while (ss >> record) {
            fields.push_back(record);
        }

        if (std::stoi(fields[0]) != studentId) {
            records.push_back(line);
        }
    }

    file.close();
    std::ofstream outfile("students.txt", std::ios::trunc);

    for (const auto& record : records) {
        outfile << record << std::endl;
    }

    outfile.close();

    std::cout << "学生信息删除成功!" << std::endl;
}

void findStudent(std::ifstream& file) {
    int studentId;

    std::cout << "\n查找学生信息\n";
    std::cout << "学号: ";
    std::cin >> studentId;

    // 检查学号是否存在
    if (students.find(studentId) == students.end()) {
        std::cout << "该学号不存在!" << std::endl;
        return;
    }

    const Student& student = students[studentId];

    std::cout << "\n学生信息:" << std::endl;
    std::cout << "学号: " << student.studentId << std::endl;
    std::cout << "姓名: " << student.name << std::endl;
    std::cout << "性别: " << student.gender << std::endl;
    std::cout << "年龄: " << student.age << std::endl;
    std::cout << "籍贯: " << student.hometown << std::endl;
    std::cout << "系别: " << student.department << std::endl;
    std::cout << "专业: " << student.major << std::endl;
    std::cout << "班级: " << student.className << std::endl;
}

void printHometownByMajor(std::ifstream& file) {
    std::string major;

    std::cout << "\n按专业输出学生籍贯表\n";
    std::cout << "专业: ";
    std::cin >> major;

    std::cout << "\n" << major << "专业学生的籍贯表:" << std::endl;

    std::string line;

    while (std::getline(file, line)) {
        std::stringstream ss(line);
        std::string record;
        std::vector<std::string> fields;

        while (ss >> record) {
            fields.push_back(record);
        }

        if (fields[6] == major) {
            std::cout << fields[4] << std::endl;
        }
    }
}

void trackStudentStatus(std::ifstream& file) {
    int studentId;

    std::cout << "\n查询学生学籍变化\n";
    std::cout << "学号: ";
    std::cin >> studentId;

    // 检查学号是否存在
    if (students.find(studentId) == students.end()) {
        std::cout << "该学号不存在!" << std::endl;
        return;
    }

    std::vector<std::string> records;
    std::string line;

    while (std::getline(file, line)) {
        std::stringstream ss(line);
        std

::string record;
        std::vector<std::string> fields;

        while (ss >> record) {
            fields.push_back(record);
        }

        if (std::stoi(fields[0]) == studentId) {
            records.push_back(line);
        }
    }

    if (records.empty()) {
        std::cout << "该学生无学籍变化记录!" << std::endl;
        return;
    }

    std::cout << "\n学生学籍变化:" << std::endl;

    for (const auto& record : records) {
        std::cout << record << std::endl;
    }
}

这个示例使用了一些高端技术,包括使用unordered_map存储学生信息,以提高数据的访问效率和快速查找。另外,使用了文件流进行学生信息的读取和写入,确保学生数据的持久化存储。同时,通过使用函数来模块化不同的操作,提高代码的可读性和可维护性。

请注意,上述示例假设学生信息存储在名为students.txt的文本文件中,并且每行包含一个学生的信息。你可以根据实际情况修改文件名和格式。

希望这个示例能够帮助到你实现学生学籍管理系统。如果有任何问题,请随时提问。

C++实现的学生学籍管理系统,效果大致如下:

img


具体的代码和实现思路,可以参考:
用C++设计一个简单的学籍管理系统:https://blog.csdn.net/newlw/article/details/125145185

#include<stdio.h>    
#include<stdlib.h>    
#include<string.h>    //头文件
  
#define LEN 20        //学号和姓名最大字符数,20
#define N 50        //最大的学生人数
  
int M = 0;//当前已经有的学生数量
  
//函数声明
  
void insert();  //录入学生信息
void modify();  //修改学生信息
void search();  //查询学生信息
void menu();    //主菜单函数
void save();    //保存学生信息
void jiguanbiao();  //输出学生籍贯信息
void xueji();   //查询学生学籍变化信息
  
//结构体保存学生信息
struct student{
    long int Id;  //学号
    char Name[LEN+1];    //姓名
    char Sex[LEN+1];    //性别
    int  Age;     //年龄
    char BirthPlace[LEN+1];    //籍贯
    char YuanXi[LEN+1];          //院系
    char ZhuanYe[LEN+1];        //专业
    int  BanJi;      //班级
    char xueji[LEN+1];//学籍变化信息
  
}stu[N];
  
//主函数
int main()
{
     
    while (1)
    {
        menu();
    }
    system("pause");
    return 0;
  
}
  
  
void menu()//菜单函数
{
  
    int num;
    printf("\n");
    printf("——————————————————————————\n");
    printf("*************欢迎使用学生信息管理系统***************\n");
    printf("*                                                  *\n");
    printf("********************系统功能菜单********************\n");
    printf("*                                                  *\n");
    printf("*                 1.添加学生信息                   *\n");
    printf("*                 2.修改学生信息                   *\n");
    printf("*                 3.查找学生信息                   *\n");
    printf("*                 4.输出学生籍贯表                 *\n");
    printf("*                 5.保存信息到文件                 *\n");
    printf("*                 6.查看学生学籍变化               *\n");
    printf("*                 7.退出系统                       *\n");
    printf("——————————————————————————\n");
    printf("请选择菜单编号:");
    scanf("%d", &num);
    switch (num)
    {
         
        case 1:
            printf("Input student number(M<=50):\n");
            scanf("%d", &M);
            insert();
            break;
        case 2:
            modify();
            break;
        case 3:
            search();
            break;
        case 4:
            jiguanbiao();
            break;
        case 5:
            save();
            break;
        case 6:
            xueji();
            break;
        case 7:
            printf("退出程序成功!\n");
            exit(0);
        default:
            printf("请在1-8之间选择\n");
            system("pause");//提示完成之后显示按任意键继续
    }
  
}
void insert()//添加学生信息
    {    int i;
        for(i=1;i<=M;i++)
        {
            printf("请输入第%d个学生的学号:",i);
            scanf("%ld",&stu[i].Id);
            printf("请输入第%d个学生的姓名:",i);
            scanf("%s",&stu[i].Name);
            printf("请输入第%d个学生的性别:",i);
            scanf("%s",&stu[i].Sex);
            printf("请输入第%d个学生的年龄:",i);
            scanf("%d",&stu[i].Age);
            printf("请输入第%d个学生的籍贯:",i);
            scanf("%s",&stu[i].BirthPlace);
            printf("请输入第%d个学生的学院:",i);
            scanf("%s",&stu[i].YuanXi);
            printf("请输入第%d个学生的专业:",i);
            scanf("%s",&stu[i].ZhuanYe);
            printf("请输入第%d个学生的班级:",i);
            scanf("%d",&stu[i].BanJi);
            printf("请输入第%d个学生的学籍(如入学、转专业、退学、降级、休学、毕业):",i);
            scanf("%s",&stu[i].xueji);
        }
        printf("学生信息添加完毕!请立即保存数据信息到文件!");
         
    }
void modify()//修改学生信息
    {
         
    int i, item;
    long int a;
    printf("请输入要修改学生的学号:\n");
    scanf("%ld",&a);
    for (i=1; i<=M; i++)
    {
        if (stu[i].Id==a)
        {
            printf("1.修改名字:\n");
            printf("2.修改性别:\n");
            printf("3.修改年龄:\n");
            printf("4.修改籍贯:\n");
            printf("5.修改学院:\n");
            printf("6.修改专业:\n");
            printf("7.修改班级:\n");
            printf("8.修改学籍\n");
            printf("0.End of program!\n");
            while (1)
            {
                printf("please choose:");
                scanf("%d", &item);
                switch (item)
                {
                case 1:
                    printf("Please input new name:\n");
                    scanf("%s", &stu[i].Name);
                    break;
                case 2:
                    printf("Please input sex:\n ");
                    scanf("%s", &stu[i].Sex);
                    break;
                case 3:
                    printf("Please input new age:\n");
                    scanf("%d", &stu[i].Age);
                    break;
                case 4:
                    printf("Please input BirthPlace:\n");
                    scanf("%s", &stu[i].BirthPlace);
                    break;
                case 5:
                    printf("Please input new yuanxi:\n");
                    scanf("%s", &stu[i].YuanXi);
                    break;
                case 6:
                    printf("Please input new zhuanye:\n");
                    scanf("%s", &stu[i].ZhuanYe);
                    break;
                case 7:
                    printf("Please input new banji:\n ");
                    scanf("%d", &stu[i].BanJi);
                    break;
                case 8:
                    printf("Please input new xueji:\n");
                    scanf("%s", &stu[i].xueji);
                    break;
                default: printf("Input error!\n");
                }
                if (item == 0)
                    break;
            }
        }
    }
  
} 
void search()  //查找已知学号的学生信息
{
    long int b,term=-1;
    int i;
    printf("请输入要查找学生的学号:");
    scanf("%ld",&b);
    for (i=1; i<=M; i++)
    {
        if (stu[i].Id==b)
        {
             
            printf("学号:%ld  姓名:%s  性别:%s  年龄:%d  籍贯:%s  学院:%s  专业:%s  班级:%d  学籍:%s  \n",stu[i].Id,stu[i].Name,stu[i].Sex,stu[i].Age,stu[i].BirthPlace,stu[i].YuanXi,stu[i].ZhuanYe,stu[i].BanJi,stu[i].xueji);
            term=-2;
        }
    }
    if(term!=-2)
    {
        printf("Not found!\n");
    }
     
}
void jiguanbiao()//按学号和专业输出学生籍贯表
    {
    int i;
  
    FILE *fp;
    fp=fopen("student.txt","r");
    printf("********************学生籍贯表*********************\n");
    printf("学号      姓名       籍贯\n");
    for(i=1;i<=M;i++)
    {  
        printf("%ld        %s         %s\n",stu[i].Id,stu[i].Name,stu[i].BirthPlace);
    }
    fclose(fp);
    }
void save()//保存学生信息到文件
    {
        int i;
     
        FILE *fp;
        fp=fopen("student.txt","w");//在工程路径下创建名为“student.txt”的记事本
  
        for(i=1;i<=M;i++)
        {
            fprintf(fp,"%ld         %s         %s         %d        %s         %s         %s         %d       %s  \n",stu[i].Id,stu[i].Name,stu[i].Sex,stu[i].Age,stu[i].BirthPlace,stu[i].YuanXi,stu[i].ZhuanYe,stu[i].BanJi,stu[i].xueji);
  
        }
        fclose(fp);
        printf("学生信息保存成功!");
    }
void xueji()   //查询学生学籍变化信息
  
    {
        long int c,t=-1;
        int i;
        printf("请输入要查询学生的学号:");
        scanf("%ld",&c);
        for (i=1; i<=M; i++)
        {
            if (c==stu[i].Id)
            {
            printf("学号:%ld  姓名:%s   学籍:%s  \n",stu[i].Id,stu[i].Name,stu[i].xueji);        
            t=-2;
            }    
        }
         
        if(t!=-2)    
        printf("Not found!\n");
 }

https://www.jb51.net/article/256380.htm