c++教职工信息
时间: 2023-07-01 17:19:16 浏览: 81
好的,以下是一个简单的C++教职工信息管理系统的代码示例:
```cpp
#include <iostream>
#include <string>
using namespace std;
struct Teacher {
string name;
int age;
string sex;
string id;
string title;
};
int main() {
int n;
cout << "请输入教职工人数:";
cin >> n;
Teacher* teachers = new Teacher[n]; // 动态分配内存
for (int i = 0; i < n; i++) {
cout << "请输入第" << i+1 << "个教职工的姓名:";
cin >> teachers[i].name;
cout << "请输入第" << i+1 << "个教职工的年龄:";
cin >> teachers[i].age;
cout << "请输入第" << i+1 << "个教职工的性别:";
cin >> teachers[i].sex;
cout << "请输入第" << i+1 << "个教职工的工号:";
cin >> teachers[i].id;
cout << "请输入第" << i+1 << "个教职工的职称:";
cin >> teachers[i].title;
}
cout << "\n教职工信息如下:" << endl;
for (int i = 0; i < n; i++) {
cout << "姓名:" << teachers[i].name << ",年龄:" << teachers[i].age << ",性别:" << teachers[i].sex << ",工号:" << teachers[i].id << ",职称:" << teachers[i].title << endl;
}
delete[] teachers; // 释放内存
return 0;
}
```
这是一个非常基本的教职工信息管理系统,它允许您输入教职工的姓名、年龄、性别、工号和职称,并将它们存储在动态分配的内存中。最后,它会打印出所有输入的教职工信息。当然,您可以根据自己的需求进行修改和扩展。
阅读全文