const n=4;
var
a:array[1..n,1..n] of integer;
max:array[1..n] of integer;
i,j,t, index,index1:integer;
begin
randomize;for i:=1 to n do
for j:=1 to n do
a[i,j]:=random(100);
max[1]:=a[1,1];
for i:=1 to n do begin
for j:=1 to n do
if a[i,j]> max[i] then
begin
max[i]:=a[i,j];
index:=i; index1:=j;
end;
t:=a[i,i];
a[i,i]:=max[i];
a[index,index1]:=t;
end;
for i:=1 to n do
writeln(max[i]);
for i:=1 to n do
begin for j:=1 to n do
write(a[i,j]:4);
writeln;
end;
readln;
end.
var
a:array[1..n,1..n] of integer;
max:array[1..n] of integer;
i,j,t, index,index1:integer;
begin
randomize;for i:=1 to n do
for j:=1 to n do
a[i,j]:=random(100);
max[1]:=a[1,1];
for i:=1 to n do begin
for j:=1 to n do
if a[i,j]> max[i] then
begin
max[i]:=a[i,j];
index:=i; index1:=j;
end;
t:=a[i,i];
a[i,i]:=max[i];
a[index,index1]:=t;
end;
for i:=1 to n do
writeln(max[i]);
for i:=1 to n do
begin for j:=1 to n do
write(a[i,j]:4);
writeln;
end;
readln;
end.