AlenAntonelli

Comando_de_Robot_Alen

May 12th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. ///Trello, Facil, Comando de robot
  2. #include <iostream> /// AlenAntonelli
  3. using namespace std;
  4. int main ()
  5. {
  6.     int x, y, xm, ym;
  7.     string ORD;
  8.     cin>>x>>y>>xm>>ym>>ORD;
  9.     for (int i=0; i<ORD.size(); i++)
  10.     {
  11.         switch (ORD[i])
  12.         {
  13.         case 'N':
  14.             if (y!=ym) y++;
  15.             break;
  16.         case 'S':
  17.             if (y!=1) y--;
  18.             break;
  19.         case 'E':
  20.             if (x!=xm) x++;
  21.             break;
  22.         case 'O':
  23.             if (x!=1) x--;
  24.             break;
  25.         }
  26.     }
  27.     cout<<x<<" "<<y;
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment