program mtr1;
const N=10;
type iint:1..10;
matrix: array [iint,iint] of integer;
var a: matrix;
i,j: iint;
m:iint;
v:integer;
begin
readln (m);
randomize;
(* заполнение матрицы *)
for i:=1 to m do
for j:=1 to m do
a[i,j] := random(21)-10;
for j:=i to m do
if i=j then
continue;
v:= a[i,j];
a[i,j] := a[j,i];
a[j,i] := v;
end;
for i:=1 m do
write(a[i,j],' ');
writeln;
end.
Объяснение:
program mtr1;
const N=10;
type iint:1..10;
matrix: array [iint,iint] of integer;
var a: matrix;
i,j: iint;
m:iint;
v:integer;
begin
readln (m);
randomize;
(* заполнение матрицы *)
for i:=1 to m do
for j:=1 to m do
a[i,j] := random(21)-10;
for i:=1 to m do
for j:=i to m do
begin
if i=j then
continue;
v:= a[i,j];
a[i,j] := a[j,i];
a[j,i] := v;
end;
for i:=1 m do
begin
for j:=1 to m do
write(a[i,j],' ');
writeln;
end;
end.
Объяснение: