Untitled
unknown
plain_text
a year ago
1.1 kB
2
Indexable
Never
#include <string> #include <iostream> using namespace std; struct Employee { string name; int accessLevel; double salary; int contractDuration; }; void calculateTotalSalary(Employee* employees, int size, double* totalSalaries) { for (int i = 0; i < size; i++) { totalSalaries[i] = employees[i].salary * employees[i].contractDuration; } } int main() { int N; N = 3; Employee* employees = new Employee[N]; employees[0].name = "John"; employees[0].accessLevel = 7; employees[0].salary = 4000.0; employees[0].contractDuration = 12; employees[1].name = "Mary"; employees[1].accessLevel = 8; employees[1].salary = 4500.0; employees[1].contractDuration = 24; employees[2].name = "Bob"; employees[2].accessLevel = 9; employees[2].salary = 5000.0; employees[2].contractDuration = 6; double* totalSalaries = new double[N]; calculateTotalSalary(employees, N, totalSalaries); for (int i = 0; i < N; i++) { cout << "Employee " << employees[i].name << ", total salary: " << totalSalaries[i] << endl; } }