Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void inputArray(int n, int* car, string what) {
- cout << "Введите цены за " << what << " :\n";
- for (int i = 0; i < n; i++) {
- cout << i + 1 << what << " = ";
- cin >> car[i];
- }
- }
- int averageSmth(int* car, int size, string what) {
- int average = 0;
- for (int i = 0; i < size; i++)
- average += car[i];
- average /= size;
- cout << "Средняя цена марок " << what << ": " << average << endl;
- return average;
- }
- int main() {
- setlocale(LC_ALL, "Russian");
- int average_cars = 0, average_moto = 0, n, m;
- cout << "Введите количество машин : ";
- cin >> n;
- int* car = new int[n];
- inputArray(n, car, " машина ");
- cout << "Введите количество мотоциклов : ";
- cin >> m;
- int* moto = new int[m];
- inputArray(m, moto, " мотоцикл ");
- average_cars = averageSmth(car, n, "машин");
- average_moto = averageSmth(moto, m, "мотоциклов");
- if (average_cars / average_moto > 3)
- cout << "\nВерно";
- else
- cout << "\nНеверно";
- delete[] car;
- delete[] moto;
- }
Advertisement
Add Comment
Please, Sign In to add comment