Предмет:
Другие предметыАвтор:
twinkieОтвет:
#include <iostream>
#include <string>
const int NUM_WORKERS = 5;
struct Worker {
std::string surname;
std::string category;
int salary;
int workshop;
};
int main() {
Worker workers[NUM_WORKERS];
// Input worker data
for (int i = 0; i < NUM_WORKERS; i++) {
std::cout << "Enter data for worker " << i + 1 << ":" << std::endl;
std::cout << "Surname: ";
std::cin >> workers[i].surname;
std::cout << "Category: ";
std::cin >> workers[i].category;
std::cout << "Salary: ";
std::cin >> workers[i].salary;
std::cout << "Workshop: ";
std::cin >> workers[i].workshop;
std::cout << std::endl;
}
// Calculate total salary for all categories
int total_salary = 0;
for (int i = 0; i < NUM_WORKERS; i++) {
total_salary += workers[i].salary;
}
// Calculate total salary for each category
int category_salary[3] = {0, 0, 0};
for (int i = 0; i < NUM_WORKERS; i++) {
if (workers[i].category == "A") {
category_salary[0] += workers[i].salary;
} else if (workers[i].category == "B") {
category_salary[1] += workers[i].salary;
} else {
category_salary[2] += workers[i].salary;
}
}
// Calculate percentage of salary for each category
float percentage_salary[3];
for (int i = 0; i < 3; i++) {
percentage_salary[i] = (float) category_salary[i] / total_salary * 100;
}
// Calculate average salary for each category
float average_salary[3];
int category_count[3] = {0, 0, 0};
for (int i = 0; i < NUM_WORKERS; i++) {
if (workers[i].category == "A") {
average_salary[0] += workers[i].salary;
category_count[0]++;
} else if (workers[i].category == "B") {
average_salary[1] += workers[i].salary;
category_count[1]++;
} else {
average_salary[2] += workers[i].salary;
category_count[2]++;
}
}
for (int i = 0; i < 3; i++) {
average_salary[i] = (float) average_salary[i] / category_count[i];
}
// Output results
std::cout << "Total salary: " << total_salary << std::endl;
std::cout << "Total salary for category
Объяснение:
не факт что будет работать
Автор:
olivertb6xДобавить свой ответ
Предмет:
Английский языкАвтор:
checkersОтветов:
Смотреть
Предмет:
ГеометрияАвтор:
estebanballОтветов:
Смотреть
Предмет:
Русский языкАвтор:
hickmanОтветов:
Смотреть