当然可以帮您写一个简单的数据管理系统。以下是一个例子,用于管理学生的信息。

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

using namespace std;

struct Student {
    string name;
    int age;
    string major;
};

vector<Student> studentList;

void addStudent() {
    Student student;
    cout << "Enter student's name: ";
    cin >> student.name;
    cout << "Enter student's age: ";
    cin >> student.age;
    cout << "Enter student's major: ";
    cin >> student.major;
    studentList.push_back(student);
    cout << "Student added successfully!" << endl;
}

void displayStudents() {
    cout << "List of students:" << endl;
    for (int i = 0; i < studentList.size(); i++) {
        cout << "Name: " << studentList[i].name << endl;
        cout << "Age: " << studentList[i].age << endl;
        cout << "Major: " << studentList[i].major << endl;
        cout << endl;
    }
}

int main() {
    int choice;
    while (true) {
        cout << "1. Add student" << endl;
        cout << "2. Display students" << endl;
        cout << "3. Quit" << endl;
        cout << "Enter your choice: ";
        cin >> choice;

        switch (choice) {
            case 1:
                addStudent();
                break;
            case 2:
                displayStudents();
                break;
            case 3:
                return 0;
            default:
                cout << "Invalid choice. Please try again." << endl;
                break;
        }
    }
}

这个简单的数据管理系统允许用户添加学生的姓名、年龄和专业,并显示已添加学生的列表。

您可以根据自己的需求修改和扩展这个代码

帮我用c++写一个数据管理系统

原文地址: http://www.cveoy.top/t/topic/h8Xy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录