Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <windows.h>
- using namespace std;
- struct Cargo
- {
- string place;
- int cost;
- int weight;
- };
- int main()
- {
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- setlocale(LC_ALL,"");
- Cargo tour[10];
- Cargo temp;
- for (int i = 0; i < 3; i++)
- {
- cout << "Место транспортировки груза : ";
- cin >> tour[i].place;
- cout << "Вес груза : ";
- cin >> tour[i].weight;
- cout << "Стоимость перевозки: ";
- cin >> tour[i].cost;
- }
- for (int i = 0; i < 3; i++)
- {
- if (tour[i].cost < tour[i+1].cost)
- {
- temp = tour[i+1];
- tour[i] = tour[i+1];
- tour[i+1] = temp;
- }
- }
- int temp1 = tour[0].cost;
- int count = 1;
- for (int i = 1; i < 3; i++)
- {
- if (tour[i].cost == tour[0].cost) count++;
- }
- cout << "\nКоличество поездок, с максимальной стоимостью : " << count << endl;
- cout << "\nПоездка, где стоимость перевезенного груза была максимальной : \n";
- for (int i = 0; i < count; i++)
- {
- cout << tour[i].place << ", вес груза (кг) " << tour[i].weight << ", стоимость (р.) " << tour[i].cost << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement