Advertisement
fabis_sparks

Lubov 2-1

Apr 18th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <cstdlib>
  5. #include "conio.h"
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12.     system("color F0");
  13.     setlocale(LC_ALL, "Russian");
  14.     int mass[3][3];
  15.     int rowCount, maxrow, colCount, maxcol, reserve;
  16.     int i, j, max;
  17.     colCount = 3;
  18.     rowCount = 3;
  19.     max = mass[0][0];
  20.     for (i = 0; i < 3; i++)
  21.     {
  22.         for (j = 0; j < 3; j++)
  23.         {
  24.             scanf_s("%d", &mass[i][j]);
  25.         }
  26.         cout << endl;
  27.     }
  28.     int maxinrow = 0;
  29.     int maxinlcol = 0;
  30.     for (i = 0; i<rowCount; i++) {
  31.         if (mass[0][i] > maxinrow)
  32.         { // Ищем максимальное в первой строке
  33.             maxinrow = mass[0][i];
  34.             maxrow = i;
  35.         }
  36.         if (mass[colCount - 1][i] > maxinlcol)
  37.         { // Ищем максимальное с последнем столбце
  38.             maxinlcol = mass[colCount - 1][i];
  39.             maxcol = i;
  40.         }
  41.     }
  42.     reserve = mass[0][maxrow]; // Меняем данные местами через резервную переменную
  43.     mass[0][maxrow] = mass[colCount - 1][maxcol];
  44.     mass[colCount - 1][maxcol] = reserve;
  45.     for (i = 0; i < 3; i++)
  46.     {
  47.         for (j = 0; j < 3; j++)
  48.         {
  49.             printf(" %d", mass[i][j]);
  50.         }
  51.         cout << endl;
  52.     }
  53.     system("pause");
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement