Program a; Var f:Text; cod:Integer; r,x,y,s,l:Real; k,p:Byte; st:String[200]; Begin k:=0; s:=0; Assign(f,'treasure.in'); Reset(f); Repeat x:=0; y:=0; k:=k+1; ReadLn(f,st); If st[1]<>'E' Then Begin For p:=1 To Length(st) Do Begin If st[p]<>'.'Then Begin Val(st[p],l,cod); If cod=0 Then s:=s*10+l; If (st[p]<>',') And (cod=1) Then Case st[p] Of 'N':Begin If st[p+1] In['E','W'] Then Begin y:=y+s/Sqrt(2); Case St[p+1] Of 'W':x:=x-s/Sqrt(2); 'E':x:=x+s/Sqrt(2); End; p:=p+1; End Else y:=y+s;s:=0; End; 'S':Begin If st[p+1] In['E','W'] Then Begin y:=y-s/Sqrt(2); Case St[p+1] Of 'W':x:=x-s/Sqrt(2); 'E':x:=x+s/Sqrt(2); End; p:=p+1; End Else y:=y-s;s:=0; End; 'E':Begin x:=x+s; s:=0; End; 'W':Begin x:=x-s; s:=0; End; End; End; End; r:=Sqrt(Sqr(x)+Sqr(y)); WriteLn('Карта #',k); WriteLn('Координаты сокровища (',x:1:3,',',y:1:3,').'); WriteLn('Расстояние до сокровища ',r:1:3,'.'); WriteLn; End; Until st[1]='E'; End.