Const
k = 3;
p = 3;
var
f: array [1..k, 1..p] of byte;
mini: array [1..2] of byte := (1, 1);
maxi: array [1..2] of byte := (1, 1);
procedure Swap(var a, b: integer);
var
p: integer;
begin
p := a;
a := b;
b := p;
end;
begin
for i: byte := 1 to k do
begin
for j: byte := 1 to p do
begin
f[i, j] := random(10, 100);
write(f[i, j]:3);
if (f[mini[1], mini[2]] > f[i, j]) then
begin
mini[1] := i;
mini[2] := j;
end;
if (f[maxi[1], maxi[2]] < f[i, j]) then
begin
maxi[1] := i;
maxi[2] := j;
end;
end;
writeln();
end;
writeln();
swap(f[1, p], f[maxi[1], maxi[2]]);
swap(f[p, 1], f[mini[1], mini[2]]);
for i: byte := 1 to k do
begin
for j: byte := 1 to p do
write(f[i, j]:3);
writeln();
end;
end.