Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <iostream>
  4. #include <clocale>
  5. using namespace std;
  6.  
  7.  
  8. void info(float x[][2])
  9. {
  10.     int i;
  11.     for (i = 0; i < 5; i++) {
  12.         cout << "\n У пассажира " << i+1 << " " << x[i][0] << " предметов багажа, весом " << x[i][1] << " кг.\n";
  13.     }
  14. }
  15.  
  16. int main()
  17. {
  18.     setlocale(LC_CTYPE, "rus");
  19.  
  20.     float passengers[5][2] = {
  21.             {5, 3},
  22.             {1, 6},
  23.             {4, 1},
  24.             {5, 7.5},
  25.             {10, 18.7}
  26.     };
  27.  
  28.     int i, nmax; float max;
  29.     for (i = 0, max = passengers[0][1], nmax = 0; i < 5; i++)
  30.         if (max < passengers[i][1])
  31.         {
  32.             max = passengers[i][1];
  33.             nmax = i;
  34.         }
  35.  
  36.     info(passengers);
  37.  
  38.     cout << "У пассажира номер " << nmax << " самый тяжёлый багаж. Количество предметов - " << passengers[nmax][0] <<
  39.     ", а вес - " << max << " кг.\n";
  40.     system("pause");
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement