uses Crt;
const
n = 3;
var
a: array[1..3, 1..3] of integer;
i, j, s: integer;
begin
ClrScr;
Randomize;
s := 0;
for i := 1 to 3 do
for j := 1 to 3 do
a[i, j] := Random(99) - 49;
Write(a[i, j]:4);
if i = j then s := s + a[i, j]
end;
Writeln
Writeln('Сумма элементов главной диагонали: ', s);
ReadKey
end.
uses Crt;
const
n = 3;
var
a: array[1..3, 1..3] of integer;
i, j, s: integer;
begin
ClrScr;
Randomize;
s := 0;
for i := 1 to 3 do
begin
for j := 1 to 3 do
begin
a[i, j] := Random(99) - 49;
Write(a[i, j]:4);
if i = j then s := s + a[i, j]
end;
Writeln
end;
Writeln('Сумма элементов главной диагонали: ', s);
ReadKey
end.