Advertisement
Guest User

3306

a guest
Oct 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.   int h, w, y, x;
  6.  
  7.   char command;
  8.   cin >> h >> w >> y >> x;
  9.   while(cin >> command)
  10.   {
  11.     if (command == 'L' && x > 1)
  12.     {
  13.       x--;
  14.     }
  15.     if (command == 'R' && x < w)
  16.     {
  17.       x++;
  18.     }
  19.     if (command == 'U' && y > 1)
  20.     {
  21.       y--;
  22.     }
  23.     if (command == 'D' && y < h)
  24.     {
  25.       y++;
  26.     }
  27.   }
  28.   cout << y << ' ' << x << endl;
  29.   return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement