Очень нужна помощь. Помогите найти ошибки - Паскаль. Условие: Дан одномерный массив, состоящий из вещественных элементов. Найти произведение элементов массива, расположенных между максимальным по модулю и минимальным по модулю элементами.

Не совсем то выводит, и модуль может как-то через abs надо. 

program proizvedenie;
var q,z,w,i,n,i1,i2:integer;
a:array[1..1000] of real;
amin,amax,pr:real;
begin
assign (input,'input.txt');
assign (output,'output.txt');
reset (input);
rewrite (output);
readln(n);
for i:=1 to n do read (a[i]);
amin:=a[1];
for i:=1 to n do
begin
if a[i]<amin then
begin
amin:=a[i];
i1:=i;
end;
end;
amax:=a[1];
for i:=1 to n do
begin
if a[i] > amax then
amax:=a[i];
i2:=i;
end;
if i2>i1 then begin
q:=i1;
w:=i2;
end
else begin
q:=i2;
w:=i1;
end;
if (w-q)>1 then begin
pr:=1;
for z:=q to w do
pr:=pr*a[z];
end
else write (0);
close (input);
close (output);
end.
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Copyright © 2024 SCHOLAR.TIPS - All rights reserved.