type TDescript = record vzdial: longint; smer: string;//TSmer; end; TBod = record X,Y: double; end; var i, ArrCnt, chyba: integer; cis: longint; pom, s, sm: string[200]; Arr: array [1..1000] of TDescript; Bod: TBod; vzd, a: double; procedure Plus(var Bod:TBod; dx,dy:double); begin Bod.X:= Bod.X+dx; Bod.Y:= Bod.Y+dy; // writeln(bod.x,' ', bod.y); readln; end; function Nuly(r: double): string; var s: string; i: integer; begin Nuly:=''; r:= abs(r); r:= r-Trunc(r); Str( Round(r*1000), s); i:= length(s); if i=1 then Nuly:= '00'+s else if i=2 then Nuly:= '0'+s else Nuly:= s; end; begin readln(s); while s<>'END' do begin Bod.X:= 0; Bod.Y:= 0; ArrCnt:=1; pom:=''; sm:=''; i:=1; repeat sm:=''; pom:=''; while s[i] in ['0'..'9'] do begin pom:= pom+s[i]; inc(i); end; Val(pom,cis,chyba); Arr[ArrCnt].Vzdial:= cis; while s[i] in ['N','E','S','W'] do begin sm:= sm+s[i]; inc(i); end; Arr[ArrCnt].Smer:= sm; // writeln(pom,#32,sm); if s[i]=',' then Inc(ArrCnt) else if s[i]='.' then break; inc(i); until false; //(i>length(s)); for i:= 1 to ArrCnt do begin pom:= Arr[i].Smer; case pom[1] of 'N': if length(pom)=1 then Plus(Bod, 0, Arr[i].Vzdial) else begin a:= Arr[i].Vzdial/Sqrt(2); if pom[2]='E' then Plus(Bod, a,a) else Plus(Bod, -a,a); end; 'S': if length(pom)=1 then Plus(Bod, 0, -Arr[i].Vzdial) else begin a:= Arr[i].Vzdial/Sqrt(2); if pom[2]='E' then Plus(Bod, a,-a) else Plus(Bod, -a,-a); end; 'W': Plus(Bod, -Arr[i].Vzdial,0); 'E': Plus(Bod, Arr[i].Vzdial,0); end; //case end; //for vzd:= Sqrt(Bod.x*Bod.x + Bod.y*Bod.y); writeLn('You can go to (', Trunc(Bod.X), '.', Nuly(Bod.X), ',', Trunc(Bod.Y), '.', Nuly(Bod.Y), '), the distance is ', Trunc(vzd), '.', Nuly(vzd) ,' steps.'); Readln(s); // break; end; end.