#include #include int main () { float north,east,pocet,diag,dist; int c,d; c = getchar(); east = 0; north = 0; pocet = 0; diag = sqrt(2) / 2; while (c != 'E'){ do { pocet = 0; while (( c >= '0') && (c <= '9')) { pocet = (c - '0' + 10 * pocet); c = getchar(); } switch (c) { case 'N':{ c = getchar(); if ((c != 'E') && (c != 'W')) north += pocet; else north += pocet * diag; if (c == 'W') { c = getchar(); east -= pocet * diag;} if (c == 'E') { east += pocet * diag; c= getchar(); } break; } case 'S':{ c = getchar(); if ((c != 'E') && (c != 'W')) north -= pocet; else north -= pocet * diag; if (c == 'W') { c = getchar(); east -= pocet * diag;} if (c == 'E') { c = getchar(); east += pocet * diag; } break; } case 'W':{ east -= pocet; c = getchar(); break; } case 'E':{ east += pocet; c = getchar(); break; } } d = c;c = getchar(); } while (d != '.'); dist = sqrt(east*east + north*north); c = (east * 10000 + 0.5); d = (north * 10000 + 0.5); east = c; north = d; east = east / 10000; north= north / 10000; printf("You can go to (%.3f,%.3f), the distance is %.3f steps.\n",east,north,dist); north = 0; east = 0; c = getchar(); } return 0; }