uses crt;
const nmax=20;
var a:array[1..nmax,1..nmax] of integer;
n,i,j,x:integer;
begin
randomize;
repeat
write('Размер матрицы до ',nmax,' n=');
read(n);
until n in [1..nmax];
writeln('Исходная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(50);
write(a[i,j]:3);
end;
writeln;
end;
writeln;
for i:=2 to n do
for j:=1 to i-1 do
begin
x:=a[i,j];
a[i,j]:=a[j,i];
a[j,i]:=x;
end;
writeln('Транспонированная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:3);
writeln;
end;
end.
const nmax=20;
var a:array[1..nmax,1..nmax] of integer;
n,i,j,x:integer;
begin
randomize;
repeat
write('Размер матрицы до ',nmax,' n=');
read(n);
until n in [1..nmax];
writeln('Исходная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(50);
write(a[i,j]:3);
end;
writeln;
end;
writeln;
for i:=2 to n do
for j:=1 to i-1 do
begin
x:=a[i,j];
a[i,j]:=a[j,i];
a[j,i]:=x;
end;
writeln('Транспонированная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:3);
writeln;
end;
end.