#include int main(void) { char line[300]; gets(line); while (*line != 'E') { float x=0,y=0; char *pline = line; while (*pline != 0 && *(pline-1)!='.') { int c=0; int px=0; int py=0; while (*pline >= '0' && *pline <= '9') c = c*10 + ((*pline++)-'0'); //\n%d\n",c); while (*pline != ',' && *pline != '.') { switch (*pline) { case 'N': py = 1; break; case 'S': py = -1;break; case 'W': px = -1;break; case 'E': px = 1;break; } pline++; } //printf("\n%d %d\n",px,py); pline++; float o = (py!=0 && px!=0) ? ((float)c/sqrt(2)):c; x += o * px; y += o * py; } printf("You can go to (%.3f %.3f), the distance is %.3f steps.\n",x,y,sqrt(x*x+y*y)); gets(line); } return 0; }