Объяснение:
C++Выделить код
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void main()
{
setlocale(0, "rus");
int mas[5][5];
srand(time(NULL));
cout << "Первоначальный массив" << endl;
for (int i = 0; i<5; i++){
cout << endl;
for (int j = 0; j<5; j++){
mas[i][j] = rand() % 10;
cout << mas[i][j] << " ";
}
cout << endl;
}
cout << "Полученный массив" << endl;
for (int i = 0; i<5; i++){
int tmp = mas[i][i];
mas[i][i] = mas[i][5 - i - 1];
mas[i][5 - i - 1] = tmp;
}
cout << endl;
for (int i = 0; i<5; i++){
cout << endl;
for (int j = 0; j<5; j++){
cout << mas[i][j] << " ";
}
cout << endl;
}
}
0
Объяснение:
C++Выделить код
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void main()
{
setlocale(0, "rus");
int mas[5][5];
srand(time(NULL));
cout << "Первоначальный массив" << endl;
for (int i = 0; i<5; i++){
cout << endl;
for (int j = 0; j<5; j++){
mas[i][j] = rand() % 10;
cout << mas[i][j] << " ";
}
cout << endl;
}
cout << "Полученный массив" << endl;
for (int i = 0; i<5; i++){
int tmp = mas[i][i];
mas[i][i] = mas[i][5 - i - 1];
mas[i][5 - i - 1] = tmp;
}
cout << endl;
for (int i = 0; i<5; i++){
cout << endl;
for (int j = 0; j<5; j++){
cout << mas[i][j] << " ";
}
cout << endl;
}
}
0
// Внимание! Если программа не работает, обновите версию!
procedure MyProc;
begin
var n:=ReadInteger('Введите порядок матрицы:');
Writeln('Введите построчно элементы матрицы');
var a:=ReadMatrInteger(n,n);
Writeln(4*a.ColCount*'-');
Write('Строки, содержащие только нули: ');
for var i:=0 to n-1 do
if a.Row(i).All(t->t=0) then Print(i+1);
Writeln
end;
begin
Loop 2 do MyProc
end.
Пример
Введите порядок матрицы: 3
Введите построчно элементы матрицы
1 0 0
0 0 1
0 0 0
Строки, содержащие только нули: 3
Введите порядок матрицы: 2
Введите построчно элементы матрицы
0 0
0 0
Строки, содержащие только нули: 1 2