Help, why crash(invalid floating point operation) at #5?
const
eps=0;
var
b:array[1..10000] of extended;
n,d,s1,e1,s2,e2:integer;
l1,l2:extended;
a:extended;
i,f,back:integer;
frontsearch,frontfound,backsearch,backfound:Boolean;
procedure SearchForFrontWall;
var
i:integer;
begin
i:=0;
frontsearch:=false;
frontfound:=false;
repeat
inc(i);
frontsearch:=b[i]-35<=eps
until (i=n) or frontsearch;
if frontsearch then
begin
repeat
inc(i);
frontfound:=b[i]-95>=eps
until (i=n) or frontfound;
if frontfound then
begin
f:=i;
writeln('Surface found at ',f,'.')
end
end
end;
procedure SearchForBackWall;
var
i:integer;
begin
i:=f;
backsearch:=false;
backfound:=false;
repeat
inc(i);
backsearch:=b[i]-35<=eps
until (i=n) or backsearch;
if backsearch then
begin
if i<f+d-1 then
i:=f+d-1;
repeat
inc(i);
backfound:=b[i]-95>=eps
until (i=n) or backfound
end;
if backfound then
begin
back:=i-f;
writeln('Bottom found at ',back,'.')
end
else
begin
writeln('No bottom.');
back:=n-f+1
end;
end;
procedure SearchChannel(num,s,e:integer;l:extended);
var
i,m:integer;
begin
if s>=back then
writeln('Channel ',num,': No search.')
else
begin
m:=s;
if e>=back then
e:=back-1;
for i:=s+1 to e do
if b[i+f]-b[m+f]>eps then
m:=i;
if b[m+f]-l>eps then
writeln('Channel ',num,': Object at ',m,'.')
else
writeln('Channel ',num,': No object.')
end
end;
begin
readln(n,d,s1,e1,l1,s2,e2,l2,a);
for i:=1 to n do
readln(b[i]);
SearchForFrontWall;
if frontfound then
begin
for i:=f+1 to n do
b[i]:=b[i]*(1+(i-f)*a);
SearchForBackWall;
SearchChannel(1,s1,e1,l1);
SearchChannel(2,s2,e2,l2)
end
else
writeln('No surface.')
end.