#include #include #include #include char s[1000]; double odm=0.5*sqrt(2); bool nl=0; int main(int ac, char ** av) { while (1) { gets(s); double x=0.0; double y=0.0; if (!strcmp(s,"END")) break; if (nl) putchar('\n'); else nl=1; char* q=s; while (*q!='.') { int steps=atoi(q); while (isdigit(*q)) q++; char c1 = *q++; double krok=1; char c2 = *q; if (isalpha(c2)) { q++; krok=odm; switch(c2){ case('S'): y-=krok*steps; break; case('N'): y+=krok*steps; break; case('W'): x-=krok*steps; break; case('E'): x+=krok*steps; break; default: //asm("hlt"); *(int *)0=0; } //switch } switch(c1){ case('S'): y-=krok*steps; break; case('N'): y+=krok*steps; break; case('W'): x-=krok*steps; break; case('E'): x+=krok*steps; break; default: //asm("hlt"); *(int *)0=0; } //switch if (*q==',') q++; } //vnitr while if (x<0.0001 && x>-0.00001) x=0; if (y<0.0001 && y>-0.00001) y=0; printf("You can go to (%.3f,%.3f), the distance is %.3f steps.", x,y,sqrt(x*x+y*y)); } //while return 0; }