Const n = 10; var a:array [1..n] of integer; i,min,imin:integer; p:longint; begin for i:=1 to n do begin a[i]:=random(21)-10; write(a[i],' '); end; writeln; min:=a[1]; imin:=1; p:=1; for i:=1 to n do begin if a[i]<min then begin min:=a[i]; imin:=i; end; if a[i]<0 then p:=p*a[i]; end; writeln('min = ',min,' imin = ',imin); writeln('p = ',p); end.
Пример: 9 5 10 -5 2 10 0 8 -8 2 min = -8 imin = 9 p = 40
Answers & Comments
Verified answer
Const n = 10;var a:array [1..n] of integer;
i,min,imin:integer; p:longint;
begin
for i:=1 to n do
begin
a[i]:=random(21)-10;
write(a[i],' ');
end;
writeln;
min:=a[1]; imin:=1;
p:=1;
for i:=1 to n do
begin
if a[i]<min then begin min:=a[i]; imin:=i; end;
if a[i]<0 then p:=p*a[i];
end;
writeln('min = ',min,' imin = ',imin);
writeln('p = ',p);
end.
Пример:
9 5 10 -5 2 10 0 8 -8 2
min = -8 imin = 9
p = 40