var a: array [1..5, 1..7] of integer;
i,j,max,min: integer;
begin
for i:=1 to 5 do
for j:=1 to 7 do
A[i,j]:=random(100);
max:=-1;
min:=101;
for i:=1 to 5 do begin
write(A[i,j]:5);
writeln();
end;
if A[i,j]>max then max:=A[i,j];
if A[i,j]<min then min:=A[i,j];
for j:=1 to 7 do begin
if A[i,j]=max then A[i,j]:=min
else if A[i,j]=min then A[i,j]:=max;
end.
var a: array [1..5, 1..7] of integer;
i,j,max,min: integer;
begin
for i:=1 to 5 do
for j:=1 to 7 do
A[i,j]:=random(100);
max:=-1;
min:=101;
for i:=1 to 5 do begin
for j:=1 to 7 do
write(A[i,j]:5);
writeln();
end;
for i:=1 to 5 do
for j:=1 to 7 do
if A[i,j]>max then max:=A[i,j];
for i:=1 to 5 do
for j:=1 to 7 do
if A[i,j]<min then min:=A[i,j];
for i:=1 to 5 do
for j:=1 to 7 do begin
if A[i,j]=max then A[i,j]:=min
else if A[i,j]=min then A[i,j]:=max;
end;
writeln();
for i:=1 to 5 do begin
for j:=1 to 7 do
write(A[i,j]:5);
writeln();
end;
end.