#include #include int main(void) { int i, d; float 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=='.') { x = (p[1]+p[3]-p[5]-p[7]) * sqrt2 + float(p[2]) - float(p[6]); y = (p[1]-p[3]-p[5]+p[7]) * sqrt2 + float(p[0]) - float(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.001) && (a>-0.001)) a = 0; */ printf("You can go to (%.3f,%.3f), the distance is %.3f steps.\n", x, y, a); x = y = 0; getchar();//gets(s); } i = 0; // while (((c1=getchar())>='0') && (c1<='9')) {i = i*10 + c1 - '0'; } scanf("%d", &i); } //printf("%d",i); return 0; }