Uses crt;
const n=5;
var a:array[1..n,1..n] of integer;
i,j,max,k,j1:integer;
begin
randomize;
for i:=1 to n do
for j:=1 to n do
a[i,j]:=random(10)-5;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:3);
writeln;
end;
writeln;
k:=1;
max:=-5;
repeat
for i:=k to k do
for j:=1 to n do
if a[i,j]>max then begin max:=a[i,j]; j1:=j;end;
a[i,j1]:=a[i,1];
max:=-5;
inc(k);
until k=n+1;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:3);
writeln;
end;
writeln;
end.