Advertisement
mercMatvey4

Untitled

Feb 12th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <windows.h>
  4. using namespace std;
  5.  
  6. struct Cargo
  7. {
  8. string place;
  9. int cost;
  10. int weight;
  11. };
  12.  
  13. int main()
  14. {
  15. SetConsoleOutputCP(1251);
  16. SetConsoleCP(1251);
  17. setlocale(LC_ALL,"");
  18. Cargo tour[10];
  19. Cargo temp;
  20. for (int i = 0; i < 3; i++)
  21. {
  22. cout << "Место транспортировки груза : ";
  23. cin >> tour[i].place;
  24. cout << "Вес груза : ";
  25. cin >> tour[i].weight;
  26. cout << "Стоимость перевозки: ";
  27. cin >> tour[i].cost;
  28. }
  29. for (int i = 0; i < 3; i++)
  30. {
  31. if (tour[i].cost < tour[i+1].cost)
  32. {
  33. temp = tour[i+1];
  34. tour[i] = tour[i+1];
  35. tour[i+1] = temp;
  36. }
  37. }
  38. int temp1 = tour[0].cost;
  39. int count = 1;
  40. for (int i = 1; i < 3; i++)
  41. {
  42. if (tour[i].cost == tour[0].cost) count++;
  43. }
  44. cout << "\nКоличество поездок, с максимальной стоимостью : " << count << endl;
  45. cout << "\nПоездка, где стоимость перевезенного груза была максимальной : \n";
  46. for (int i = 0; i < count; i++)
  47. {
  48. cout << tour[i].place << ", вес груза (кг) " << tour[i].weight << ", стоимость (р.) " << tour[i].cost << endl;
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement