#include #include #include int main(void) { float x,y; // int ch; int zavora; int cislo; // char retez[10]; float steps=0; char ch,ch2,ch3; zavora=1; x=0; y=0; while (zavora) { if (scanf("%d",&cislo)==EOF) break; //scanf("%d",&cislo); scanf("%c",&ch); scanf("%c",&ch2); if ((ch2!='.')&&(ch2!=',')){ scanf("%c",&ch3); //kdyz mam dve pismena switch (ch) { case 'N':switch (ch2) { case 'E':x=x+cislo*cos(M_PI/4); y=y+cislo*sin(M_PI/4); break; case 'W':x=x-cislo*cos(M_PI/4); y=y+cislo*sin(M_PI/4); break; }break; case 'S':switch(ch2) { case 'W':x=x-cos(cislo);y=y-sin(cislo);break; case 'E':x=x+cos(cislo);y=y-sin(cislo);break; }break; }//switch vrch }//konec if else{ // kdyz mam jedno pismeno switch (ch) { case 'N':y=y+cislo;break; case 'E':x=x+cislo;break; case 'S':y=y-cislo;break; case 'W':x=x-cislo;break; } } if ((ch2=='.')||(ch3=='.')) { if(fabsf(x)==0){x=0;} if(fabsf(y)==0){y=0;} steps=sqrt(x*x+y*y); if(fabsf(steps)==0){steps=0;} printf("You can go to (%.3f,%.3f), the distance is %.3f steps.\n",x,y,steps); x=0; y=0; } } return (0); }