#include #include int main(void) { int i, d; double a, x, y, sqrt2; long int p[8]; for (i=0;i<8;i++) p[i]=0; int c1, c2; sqrt2 = sqrt(2) / 2; i = 0; scanf("%d",&i); while (i>0) { //printf("%d",i); c1 = getchar(); c2 = getchar(); //printf("'%c' '%c'\n",c1,c2); switch (c1) { case 'N': { if (c2=='E') { d=1; c2=getchar(); } else if (c2=='W') { d=7; c2=getchar(); } else d=0; break; } case 'E': { d=2; break; } case 'S': { if (c2=='E') { d=3; c2=getchar(); } else if (c2=='W') { d=5; c2=getchar(); } else d=4; break; } case 'W': { d=6; break; } } // endswitch p[d] += i; // if (c2!=',') printf("pruser\n"); if (c2=='.') { x = double(p[1]+p[3]-p[5]-p[7]) * sqrt2 + double(p[2]) - double(p[6]); y = double(p[1]-p[3]-p[5]+p[7]) * sqrt2 + double(p[0]) - double(p[4]); for (i=0;i<8;i++) p[i]=0; a = sqrt(x*x + y*y); if ((x<0.001) && (x>-0.001)) x = 0; if ((y<0.001) && (y>-0.001)) y = 0; if ((a<0.0009) && (a>-0.0009)) a = 0; printf("You can go to (%.3f,%.3f), the distance is %.3f steps.\n", x, y, a); getchar();//gets(s); } i = 0; scanf("%d", &i); } //printf("%d",i); return 0; }