artemgf

Такси для программистов

Mar 19th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <set>
  5. #include <map>
  6. #include <algorithm>
  7. #include <string>
  8. #include <math.h>
  9. #include <vector>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     int data[6][6];
  16.     int n, one, two, three, four;
  17.  
  18.     for (int i = 1; i <= 5; i++)
  19.         for (n = 1; n <= 5; n++)
  20.             cin >> data[i][n];
  21.     one = data[1][1]+data[1][2]+data[2][3]+data[3][4]+data[4][5];
  22.     two = data[1][1] + data[1][3] + data[3][2] + data[2][4] + data[4][5];
  23.     three = data[1][1] + data[1][3] + data[3][4] + data[4][2] + data[2][5];
  24.     four = data[1][1] + data[1][4] + data[4][3] + data[3][2] + data[2][5];
  25.  
  26.     if (one <= two&& one <= three && one <= four)
  27.     {
  28.         cout << one << endl;
  29.         cout << "1 2 3 4 5" << endl;
  30.     }
  31.     else
  32.         if (two <= one&& two <= three && two <= four)
  33.         {
  34.             cout << two << endl;
  35.             cout << "1 3 2 4 5" << endl;
  36.         }
  37.         else
  38.             if (three <= one&& three <= two && three <= four)
  39.             {
  40.                 cout << three << endl;
  41.                 cout << "1 3 4 2 5" << endl;
  42.             }
  43.             else
  44.             {
  45.                 cout << four << endl;
  46.                 cout << "1 4 3 2 5" << endl;
  47.             }
  48.     _getch();
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment