Const
n=6;
var
a:array[1..n,1..n]of integer;
b:array[1..n]of integer;
i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(100);
write(a[i,j]:4);
end;
b[i]:=a[i,i];
writeln;
end;
writeln;
for i:=1 to n do
write(b[i]:4);
end.
вариант главной и побочной диагонали в одномерный массив
const
n=6;
var
a:array[1..n,1..n]of integer;
b:array[1..n*2]of integer;
i,j,k:integer;
begin
writeln;
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(100);
write(a[i,j]:4);
end;
k:=k+1;
b[k]:=a[i,i];
k:=k+1;
b[k]:=a[i,n+1-i];
writeln;
end;
writeln;
for i:=1 to n*2 do
write(b[i]:4);
end.