#include #include #include #include //清屏函数需要的头文件

using namespace std;

// 员工信息结构体 struct Employee { int id; //编号 string name; //姓名 string gender; //性别 string birthdate; //出生日期 string education; //学历 string department; //部门 string photo; //照片 string phone; //联系电话 string address; //联系地址 string idCard; //身份证号码 };

// 部门信息结构体 struct Department { int id; //编号 string name; //部门名称 };

// 定义全局变量 vector employees; //员工信息 vector departments; //部门信息 bool isLoggedIn = false; //登录状态

// 登录管理函数 void login() { string username, password; cout << "请输入用户名: "; cin >> username; cout << "请输入密码: "; cin >> password; // 假设用户名和密码都是admin if (username == "zcq" && password == "123123") { cout << "登录成功!" << endl; isLoggedIn = true; } else { cout << "用户名或密码错误!" << endl; isLoggedIn = false; } }

// 输出员工信息 void printEmployeeInfo(Employee employee) { cout << employee.id << "\t"; cout << employee.name << "\t"; cout << employee.gender << "\t"; cout << employee.birthdate << "\t"; cout << employee.education << "\t"; cout << employee.department << "\t"; cout << employee.photo << "\t"; cout << employee.phone << "\t"; cout << employee.address << "\t"; cout << employee.idCard << endl; }

// 输出部门信息 void printDepartmentInfo(Department department) { cout << department.id << "\t"; cout << department.name << endl; }

// 显示员工信息 void displayEmployees() { system("clear"); //清屏 cout << "编号\t姓名\t性别\t出生日期\t学历\t部门\t照片\t联系电话\t联系地址\t身份证号码" << endl; // 遍历员工信息列表,输出员工信息 for (int i = 0; i < employees.size(); i++) { printEmployeeInfo(employees[i]); } }

// 显示部门信息 void displayDepartments() { system("clear"); //清屏 cout << "编号\t部门名称" << endl; // 遍历部门信息列表,输出部门信息 for (int i = 0; i < departments.size(); i++) { printDepartmentInfo(departments[i]); } }

// 添加员工信息 void addEmployee() { Employee employee; cout << "请输入员工信息:" << endl; cout << "编号:"; cin >> employee.id; cout << "姓名:"; cin >> employee.name; cout << "性别:"; cin >> employee.gender; cout << "出生日期:"; cin >> employee.birthdate; cout << "学历:"; cin >> employee.education; cout << "部门:"; cin >> employee.department; cout << "照片:"; cin >> employee.photo; cout << "联系电话:"; cin >> employee.phone; cout << "联系地址:"; cin >> employee.address; cout << "身份证号码:"; cin >> employee.idCard; // 添加员工信息到员工信息列表中 employees.push_back(employee); cout << "添加成功!" << endl; }

// 修改员工信息 void modifyEmployee() { int id; cout << "请输入要修改的员工编号:"; cin >> id; // 查找员工信息列表中是否存在该员工 bool found = false; for (int i = 0; i < employees.size(); i++) { if (employees[i].id == id) { found = true; cout << "请输入修改后的员工信息:" << endl; cout << "姓名:"; cin >> employees[i].name; cout << "性别:"; cin >> employees[i].gender; cout << "出生日期:"; cin >> employees[i].birthdate; cout << "学历:"; cin >> employees[i].education; cout << "部门:"; cin >> employees[i].department; cout << "照片:"; cin >> employees[i].photo; cout << "联系电话:"; cin >> employees[i].phone; cout << "联系地址:"; cin >> employees[i].address; cout << "身份证号码:"; cin >> employees[i].idCard; cout << "修改成功!" << endl; break; } } if (!found) { cout << "不存在该员工" << endl; }

2023530 225621#include iostream#include vector#include algorithmusing namespace std; 员工信息结构体struct Employee int id; 编号 string name; 姓名 string gender; 性别 string birthdate; 出生日期 string e

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

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