Const n=3; var a:array[1..n,1..n] of integer; i,j,c:integer; begin Randomize; writeln('Исходная матрица:'); for i:= 1 to n do begin for j:=1 to n do begin a[i,j]:=random(10); write(a[i,j]:4); end; writeln; end; for i:=1 to n do for j:=i+1 to n do begin c:=a[i,j]; a[i,j]:=a[j,i]; a[j,i]:=c; end; writeln('Транспонированная матрица:'); for i:=1 to n do begin for j:=1 to n do write(a[i,j]:4); writeln; end; end.
Answers & Comments
Verified answer
Const n=3;var a:array[1..n,1..n] of integer;
i,j,c:integer;
begin
Randomize;
writeln('Исходная матрица:');
for i:= 1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(10);
write(a[i,j]:4);
end;
writeln;
end;
for i:=1 to n do
for j:=i+1 to n do
begin c:=a[i,j]; a[i,j]:=a[j,i]; a[j,i]:=c; end;
writeln('Транспонированная матрица:');
for i:=1 to n do
begin
for j:=1 to n do write(a[i,j]:4);
writeln;
end;
end.
Пример:
Исходная матрица:
1 4 4
8 3 9
8 2 1
Транспонированная матрица:
1 8 8
4 3 2
4 9 1