PascalABC.NET
const
n = 3;
var
a : array [1..n,1..n] of string;
smax : string;
i,j,lmin,lmax,km : integer;
begin
lmax := 0;
smax := '';
for i := 1 to n do
for j := 1 to n do
begin
readln (a[i,j]);
if Length (a[i,j]) > lmax then
begin
smax := a[i,j];
lmax := Length (a[i,j]);
end;
end;
lmin := Length (a[1,1]);
km := 1;
for i := 2 to n do
if Length (a[i,i]) < lmin then
begin
lmin := Length (a[i,i]);
km := i;
end;
writeln ();
for i := 1 to n do
begin
for j := 1 to n do
write (a[i,j],' ');
writeln ();
end;
writeln ();
for i := 1 to n do
begin
for j := 1 to n do
if (i = km) and (j = km) then
write (smax,' ')
else
write (a[i,j],' ');
writeln ();
end;
end.