Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <locale>
- using namespace std;
- int main() {
- string s;
- int n, m, coorX = 0, coorY = 0;
- cin >> s;
- cin >> n >> m;
- char** matr = new char* [n];
- for (int i = 0; i < n; i++)
- {
- matr[i] = new char[m];
- for (int j = 0; j < m; j++)
- matr[i][j] = 'X';
- }
- for (int i = 0; i < s.size(); i++)
- {
- matr[coorX][coorY] = '*';
- if (s[i] == 'L')
- coorY--;
- if (s[i] == 'R')
- coorY++;
- if (s[i] == 'D')
- coorX++;
- if (s[i] == 'U')
- coorX--;
- }
- matr[coorX][coorY] = '*';
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- cout << matr[i][j];
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement