编写员工工资管理程序代码
时间: 2023-05-12 22:04:16 浏览: 42
非常感谢您的提问。以下是一个简单的员工工资管理程序代码示例:
#include <iostream>
#include <string>
using namespace std;
struct Employee {
string name;
int id;
double salary;
};
int main() {
const int NUM_EMPLOYEES = 3;
Employee employees[NUM_EMPLOYEES];
for (int i = 0; i < NUM_EMPLOYEES; i++) {
cout << "Enter employee name: ";
getline(cin, employees[i].name);
cout << "Enter employee ID: ";
cin >> employees[i].id;
cout << "Enter employee salary: ";
cin >> employees[i].salary;
cin.ignore(); // Ignore newline character
cout << endl;
}
cout << "Employee information:" << endl;
for (int i = 0; i < NUM_EMPLOYEES; i++) {
cout << "Name: " << employees[i].name << endl;
cout << "ID: " << employees[i].id << endl;
cout << "Salary: $" << employees[i].salary << endl << endl;
}
return 0;
}
希望这个代码示例能够帮助您。