Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <iomanip>
- #include <ctime>
- #include <conio.h>
- #define N 5
- #define M 5
- using namespace std;
- int main()
- {
- srand(time(NULL));
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int i, j,s=0,mas[N][M],m=0;
- for (i = 0; i < N; i++)
- {
- cout << "Введите элементы " << i+1 << " строки" << endl;
- for (j = 0; j < M; j++)
- {
- cin >> mas[i][j];
- }
- }
- for (i = 0; i < N; i+=1)
- {
- m = mas[i][0];
- for (j = 1; j < M; j++)
- {
- if (mas[i][j] > m)
- m = mas[i][j];
- }
- }
- cout << "Максимальный элемент в четной строке: ";
- cout << m << endl;
- for (j = 0; j < M; j++)
- {
- for (i = 0; i < N; i++)
- s += mas[i][j];
- if (s == 0) {
- for (i = 0; i < N; i++)
- mas[i][j] = m;
- break;
- }
- s = 0;
- }
- }
- for (i = 0; i < N; i++)
- {
- for (j = 0; j < M; j++)
- {
- cout << setw(5) << mas[i][j];
- }
- cout << endl;
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement