Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int h, w, y, x;
- char command;
- cin >> h >> w >> y >> x;
- while(cin >> command)
- {
- if (command == 'L' && x > 1)
- {
- x--;
- }
- if (command == 'R' && x < w)
- {
- x++;
- }
- if (command == 'U' && y > 1)
- {
- y--;
- }
- if (command == 'D' && y < h)
- {
- y++;
- }
- }
- cout << y << ' ' << x << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement