#include #include #include #include int main(void) { long int run, i, j, a; double x = 0, y = 0; char pole[10000][200], b[200], cislo[100]; for (run = 0; ; run++) { x = 0; y = 0; scanf("%s", pole[run]); if (strcmp(pole[run], "END") == 0) { return 0; } i = 0; while (pole[run][i] != '.') { j = 0; while ((pole[run][i] >= '0') & (pole[run][i] <= '9')) { cislo[j] = pole[run][i]; cislo[j + 1] = 0; j++; i++; } j = 0; while ((pole[run][i] != ',') & (pole[run][i] != '.')) { b[j] = pole[run][i]; b[j + 1] = 0; i++; j++; } if (pole[run][i] == ',') { i++; } a = atoi(cislo); if (strcmp(b, "N") == 0) { x += a; } if (strcmp(b, "S") == 0) { x -= a; } if (strcmp(b, "E") == 0) { y += a; } if (strcmp(b, "W") == 0) { y -= a; } if (strcmp(b, "NE") == 0) { y += a / sqrt(2); x += a / sqrt(2); } if (strcmp(b, "SE") == 0) { y -= a / sqrt(2); x += a / sqrt(2); } if (strcmp(b, "SW") == 0) { y -= a / sqrt(2); x -= a / sqrt(2); } if (strcmp(b, "NW") == 0) { y += a / sqrt(2); x -= a / sqrt(2); } } printf("You can go to (%0.3f,%0.3f), the distance is %0.3f steps.\n", x, y, sqrt(x * x + y * y)); } return 0; }