65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
|
#include <iostream>
|
||
|
#include <string>
|
||
|
#include <windows.h>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
struct Employee {
|
||
|
string surname;
|
||
|
string position;
|
||
|
string education;
|
||
|
int birth_year;
|
||
|
double salary;
|
||
|
};
|
||
|
|
||
|
int main() {
|
||
|
|
||
|
SetConsoleOutputCP(CP_UTF8);
|
||
|
|
||
|
int n;
|
||
|
cout << "Введіть кількість працівників: ";
|
||
|
cin >> n;
|
||
|
|
||
|
Employee* employees = new Employee[n];
|
||
|
|
||
|
// ввід даних про кожного працівника
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
cout << "Введіть дані про працівника #" << i + 1 << ":" << endl;
|
||
|
cout << "Призвіще: ";
|
||
|
cin >> employees[i].surname;
|
||
|
cout << "Посада: ";
|
||
|
cin >> employees[i].position;
|
||
|
cout << "Освіта: ";
|
||
|
cin >> employees[i].education;
|
||
|
cout << "Рік народження: ";
|
||
|
cin >> employees[i].birth_year;
|
||
|
cout << "Зарплатня: ";
|
||
|
cin >> employees[i].salary;
|
||
|
}
|
||
|
|
||
|
// обчислення середнього значення зарплатні
|
||
|
double total_salary = 0;
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
total_salary += employees[i].salary;
|
||
|
}
|
||
|
double average_salary = total_salary / n;
|
||
|
|
||
|
// відбір працівників зарплатня яких більше середнього значення
|
||
|
int count = 0;
|
||
|
Employee* selected_employees = new Employee[n];
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
if (employees[i].salary > average_salary) {
|
||
|
selected_employees[count] = employees[i];
|
||
|
count++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// вивід результатів
|
||
|
cout << "Працівники із ЗП вище середньої:" << endl;
|
||
|
for (int i = 0; i < count; i++) {
|
||
|
cout << selected_employees[i].surname << " (" << selected_employees[i].position << "): " << selected_employees[i].salary << endl;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|