pascal
Объяснение:
const n = 5; m = 5;
var a: array [1..n, 1..m] of integer;
procedure fillarray(k: integer);
var i, j: integer;
begin
randomize;
for i := 1 to n do
for j := 1 to m do a[i, j] := random(k);
end;
procedure transarray();
var i, j, k: integer;
for j := i+1 to m do
k := a[i, j];
a[i, j] := a[j, i];
a[j, i] := k;
procedure printarray();
for i:=1 to n do
for j:=1 to m do
write(a[i, j]:3);
writeln;
fillarray(10);
printarray();
transarray();
end.
pascal
Объяснение:
const n = 5; m = 5;
var a: array [1..n, 1..m] of integer;
procedure fillarray(k: integer);
var i, j: integer;
begin
randomize;
for i := 1 to n do
for j := 1 to m do a[i, j] := random(k);
end;
procedure transarray();
var i, j, k: integer;
begin
for i := 1 to n do
for j := i+1 to m do
begin
k := a[i, j];
a[i, j] := a[j, i];
a[j, i] := k;
end;
end;
procedure printarray();
var i, j: integer;
begin
for i:=1 to n do
begin
for j:=1 to m do
write(a[i, j]:3);
writeln;
end;
writeln;
end;
begin
fillarray(10);
printarray();
transarray();
printarray();
end.