why does it crash ( flt_invalid_operation)? Have a look, please!
var st,st1,st2,st3,st4 :string;
x,y,z,v,k :array[1..2] of extended;
r,kc :extended;
procedure doc(var st :string; var t :extended);
begin
t := 0;
while ( st[1] >= '0') and ( st[1] <= '9' ) do
begin t := t * 10 + ord( st[1] ) - 48;
delete(st,1,1);
end;
delete(st,1,1);
end;
procedure doc1(var st :string; var t :extended);
var x,y,z :extended;
begin
while ( st[1] < '0' ) or ( st[1] > '9' ) do delete(st,1,1);
doc(st, x); doc(st,y); doc(st, z);
t := x + y/60 + z/3600;
t := t * pi / 180;
if ( pos('SL',st) > 0 ) or ( pos('WL',st) > 0 )
then t := -t;
end;
procedure input;
begin
readln( st);
readln( st);
readln( st);
readln( st1);
readln( st2);
readln( st);
readln( st3);
readln( st4);
doc1(st1, v[1]); doc1(st2, k[1]);
doc1(st3, v[2]); doc1(st4, k[2]);
end;
procedure tinh_toa_do;
begin
r := 6875/2;
x[1] := r * sin( v[1] );
y[1] := r * cos( v[1] ) * sin( k[1] );
z[1] := r * cos( v[1] ) * cos( k[1] );
x[2] := r * sin( v[2] );
y[2] := r * cos( v[2] ) * sin( k[2] );
z[2] := r * cos( v[2] ) * cos( k[2] );
end;
procedure tinh_khoang_cach;
var canh,co,goc :extended;
begin
canh := sqrt( sqr( x[1] - x[2] ) + sqr( y[1] - y[2] ) +
sqr( z[1] - z[2] ) );
co := ( 2*sqr(r) - sqr(canh) ) / ( 2 * sqr(r) );
if co = 0 then goc := pi/2
else goc := arctan( sqrt( 1/sqr(co) - 1 ) );
kc := r * goc;
end;
procedure solve;
begin
tinh_toa_do;
tinh_khoang_cach;
end;
procedure out;
begin
writeln('The distance to the iceberg: ',kc:0:2,' miles.');
if kc < 99.95 then writeln('DANGER!');
end;
begin
input;
solve;
out;
end.