Re: sample
my code is:
program titanic;
uses math;
const r=3437.5;
var s:char;
a,b,c,x,y,z,d,e,u,v,w:extended;
begin
assign(input,'titanic.in');
assign(output,'titanic.out');
reset(input);
rewrite(output);
readln;
readln;
readln;
read(s);
while s<>'^' do
begin
a:=a*10+ord(s)-48;
read(s);
end;
read(s);
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
read(s);
end;
a:=a+z/60;
z:=0;
read(s);
while s<>'"' do
begin
z:=z*10+ord(s)-48;
read(s);
end;
read(s,s);
a:=a+z/3600;
if s='S' then
a:=-a;
readln;
read(s,s,s,s,s);
while s<>'^' do
begin
b:=b*10+ord(s)-48;
read(s);
end;
read(s);
z:=0;
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
read(s);
end;
b:=b+z/60;
z:=0;
read(s);
while s<>'"' do
begin
z:=z*10+ord(s)-48;
read(s);
end;
read(s,s);
b:=b+z/3600;
if s='W' then
b:=-b;
readln;
readln;
read(s);
while s<>'^' do
begin
x:=x*10+ord(s)-48;
read(s);
end;
read(s);
z:=0;
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
read(s);
end;
x:=x+z/60;
z:=0;
read(s);
while s<>'"' do
begin
z:=z*10+ord(s)-48;
read(s);
end;
read(s,s);
x:=x+z/3600;
if s='S' then
x:=-x;
readln;
read(s,s,s,s,s);
while s<>'^' do
begin
y:=y*10+ord(s)-48;
read(s);
end;
read(s);
z:=0;
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
read(s);
end;
y:=y+z/60;
z:=0;
read(s);
while s<>'"' do
begin
z:=z*10+ord(s)-48;
read(s);
end;
read(s,s);
y:=y+z/3600;
if s='W' then
y:=-y;
c:=sin(a);
z:=cos(a);
d:=z*cos(b);
e:=z*sin(b);
u:=sin(x);
z:=cos(x);
v:=z*cos(y);
w:=z*sin(y);
z:=c*u+d*v+e*w;
z:=r*pi*arccos(z)/180;
writeln('The distance to the iceberg: ',z:0:8,' miles.');
if z<99.995 then
writeln('DANGER!');
end.