Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "stdafx.h"
- #include <iostream>
- #include <cstdlib>
- #include "conio.h"
- using namespace std;
- int main()
- {
- system("color F0");
- setlocale(LC_ALL, "Russian");
- int mass[3][3];
- int rowCount, maxrow, colCount, maxcol, reserve;
- int i, j, max;
- colCount = 3;
- rowCount = 3;
- max = mass[0][0];
- for (i = 0; i < 3; i++)
- {
- for (j = 0; j < 3; j++)
- {
- scanf_s("%d", &mass[i][j]);
- }
- cout << endl;
- }
- int maxinrow = 0;
- int maxinlcol = 0;
- for (i = 0; i<rowCount; i++) {
- if (mass[0][i] > maxinrow)
- { // Ищем максимальное в первой строке
- maxinrow = mass[0][i];
- maxrow = i;
- }
- if (mass[colCount - 1][i] > maxinlcol)
- { // Ищем максимальное с последнем столбце
- maxinlcol = mass[colCount - 1][i];
- maxcol = i;
- }
- }
- reserve = mass[0][maxrow]; // Меняем данные местами через резервную переменную
- mass[0][maxrow] = mass[colCount - 1][maxcol];
- mass[colCount - 1][maxcol] = reserve;
- for (i = 0; i < 3; i++)
- {
- for (j = 0; j < 3; j++)
- {
- printf(" %d", mass[i][j]);
- }
- cout << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement