Const n=15;
var a:array[1..n] of integer;
i,max,imax:integer; p:real;
begin
Randomize;
for i:=1 to n do begin
a[i]:=random(21);
write(a[i]:3);
end;
writeln;
max:=a[1]; imax:=1;
for i:=2 to n do
if a[i]>max
then begin max:=a[i]; imax:=i; end;
writeln('max = ',max,' imax = ',imax);
p:=1;
if imax > n div 2+1
then for i:=n div 2+2 to imax-1 do p:=p*a[i]
else for i:=imax+1 to n div 2 do p:=p*a[i];
writeln('p = ',p);
end.
Пример:
16 14 14 20 6 12 16 15 7 0 19 17 0 7 14
max = 20 imax = 4
p = 1152