Const n=10; var a:array[1..n,1..n] of integer; i,j:integer; p1,p2:real; begin Randomize; writeln('Исходный массив:'); for i:=1 to n do begin for j:=1 to n do begin a[i,j]:=random(20); write(a[i,j]:4); end; writeln; end; p1:=1; p2:=1; for i:=1 to n do begin p1:=p1*a[i,i]; p2:=p2*a[i,n-i+1] end; writeln('p1 = ',p1,' p2 = ',p2); end.
var
a:array[1..n,1..n] of integer;
i,j:integer; p1,p2:real;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(20);
write(a[i,j]:4);
end;
writeln;
end;
p1:=1; p2:=1;
for i:=1 to n do
begin
p1:=p1*a[i,i];
p2:=p2*a[i,n-i+1]
end;
writeln('p1 = ',p1,' p2 = ',p2);
end.
Пример (для n=5):
Исходный массив:
1 10 14 0 5
12 13 13 5 0
7 7 8 7 14
5 11 3 17 14
12 1 19 17 10
p1 = 17680 p2 = 26400