const n=5;
m=5;
var b:array[1..n,1..m]of integer;
i,j,jmx,jmn,t:integer;
begin
randomize;
for i:=1 to n do
begin
for j:=1 to n do
begin
b[i,j]:=random(11)-5;
write(b[i,j]:3);
end;
writeln;
end;
for i:=1 to n do
begin
jmx:=1; jmn:=1;
for j:=1 to m do
begin
if b[i,j]>b[i,jmx] then jmx:=j;
if b[i,j]<b[i,jmn] then jmn:=j;
end;
t:=b[i,jmx]; b[i,jmx]:=b[i,1]; b[i,1]:=t;
t:=b[i,jmn]; b[i,jmn]:=b[i,m]; b[i,m]:=t;
end;
writeln('Результат:');
for i:=1 to n do
begin
for j:=1 to m do
write(b[i,j]:3);
writeln;
end;
readln;
end.
m=5;
var b:array[1..n,1..m]of integer;
i,j,jmx,jmn,t:integer;
begin
randomize;
for i:=1 to n do
begin
for j:=1 to n do
begin
b[i,j]:=random(11)-5;
write(b[i,j]:3);
end;
writeln;
end;
for i:=1 to n do
begin
jmx:=1; jmn:=1;
for j:=1 to m do
begin
if b[i,j]>b[i,jmx] then jmx:=j;
if b[i,j]<b[i,jmn] then jmn:=j;
end;
t:=b[i,jmx]; b[i,jmx]:=b[i,1]; b[i,1]:=t;
t:=b[i,jmn]; b[i,jmn]:=b[i,m]; b[i,m]:=t;
end;
writeln('Результат:');
for i:=1 to n do
begin
for j:=1 to m do
write(b[i,j]:3);
writeln;
end;
readln;
end.