#include #include int main(void) { double x=0.0,y=0.0; float konst; int step,kon; char direc,direc2,tmp; do{ konst=x=y=0.0; kon=0; do{ step=-1; scanf("%d",&step); scanf("%c",&direc); scanf("%c",&direc2); if(step==-1) { scanf("%c%c\n", &direc, &direc2) return 0; } if((direc2!=',')&&(direc2!='.')) scanf("%c",&tmp); konst=(float)step/sqrt(2.0); if((direc=='N') && (direc2=='E')){ y=y+konst; x=x+konst; }else if((direc=='S') && (direc2=='E')){ y=y-konst; x=x+konst; }else if((direc=='S') && (direc2=='W')){ y=y-konst; x=x-konst; }else if((direc=='N') && (direc2=='W')){ y=y+konst; x=x-konst; }else if(direc=='N'){ y=y+step; }else if(direc=='E'){ x=x+step; }else if(direc=='S'){ y=y-step; }else if(direc=='W'){ x=x-step; } if((tmp=='.') || (direc2=='.')){ scanf("%c",&tmp); printf("You can go to (%.3f,%.3f), the distance is %.3f steps.\n",x,y,sqrt((x*x)+(y*y))); kon=1; } }while(kon!=1); }while(1); return 0; }