//Pascal ABC.NET 3.1 сборка 1256
Const
n=4;
Var
ma:array[1..n,1..n] of integer;
i,j:integer;
begin
randomize;
writeln('Matrix:');
for i:=1 to n do
begin
for j:=1 to n do
begin
ma[i,j]:=random(10);
write(ma[i,j]:4);
end;
writeln;
end;
for i:=1 to n div 2 do
begin
swap(ma[i,i],ma[n-i+1,n-i+1]);
swap(ma[i,n-i+1],ma[n-i+1,i]);
end;
writeln('Final matrix:');
for i:=1 to n do
begin
for j:=1 to n do
write(ma[i,j]:4);
writeln;
end;
end.