Professional Documents
Culture Documents
// 1
#include <bits/stdc++.h>
class Worker {
string name;
int productivity;
int salary;
public:
Worker() {
cin >> name >> productivity >> salary;
}
int getSalary() {
return salary;
}
int getProductivity() {
return productivity;
}
};
class Mechanism {
string name;
int details;
int cost;
int wCount;
Worker *workers;
public:
Mechanism() {
cin >> name >> details >> cost >> wCount;
workers = new Worker[wCount];
}
Worker getWorker(int i) {
return workers[i];
}
string getName() {
return name;
}
int amountOfDetails() {
int details = 0;
for (int i = 0; i < wCount; i++) {
details += getWorker(i).getProductivity();
}
return details;
}
int sumSalary() {
int salary = 0;
for (int i = 0; i < wCount; i++) {
salary += getWorker(i).getSalary();
}
return salary;
}
int month() {
return ceil(details / double(amountOfDetails()));
}
int total() {
return cost - (month() * sumSalary());
}
};
int main() {
int size;
cin >> size;
int sum = 0;
for (int i = 0; i < size; ++i) {
Mechanism mechanism;
cout << mechanism.getName() << " = " << mechanism.total() << '\n';
sum += mechanism.total();
}
cout << "Total income = " << sum;
}
// 2
#include <iostream>
#include <vector>
class Student {
private:
string name;
string course;
int money;
public:
Student() {
cin >> name >> course >> money;
}
class Course {
private:
string name;
int minStudents{}, cost{};
vector<Student> listOfStudents;
public:
Course() {
cin >> name >> minStudents >> cost;
}
int calculateProfit() {
int profit = 0;
for (Student iter: listOfStudents) {
profit += cost;
}
return profit;
}
int main() {
int n, m;
cin >> n;
vector<Course> courses(n);
cin >> m;
vector<Student> students(m);