var a: array[1..4, 1..4] of integer; i, j, s, n: integer;begin for i := 1 to 4 do begin for j := 1 to 4 do begin a[i, j] := random(10); write(a[i, j], ' '); inc(n); if(n mod 4 = 0) then writeln; end; s := s + a[i, i]; end; writeln(s);end.
var
a: array[1..4, 1..4] of integer;
i, j, s, n: integer;
begin
for i := 1 to 4 do begin
for j := 1 to 4 do begin
a[i, j] := random(10);
write(a[i, j], ' ');
inc(n);
if(n mod 4 = 0) then writeln;
end;
s := s + a[i, i];
end;
writeln(s);
end.