Advertisement
AmidamaruZXC

Untitled

Oct 22nd, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <locale>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     string s;
  9.     int n, m, coorX = 0, coorY = 0;
  10.     cin >> s;
  11.     cin >> n >> m;
  12.     char** matr = new char* [n];
  13.     for (int i = 0; i < n; i++)
  14.     {
  15.         matr[i] = new char[m];
  16.         for (int j = 0; j < m; j++)
  17.             matr[i][j] = 'X';
  18.     }
  19.  
  20.     for (int i = 0; i < s.size(); i++)
  21.     {
  22.         matr[coorX][coorY] = '*';
  23.         if (s[i] == 'L')
  24.             coorY--;
  25.         if (s[i] == 'R')
  26.             coorY++;
  27.         if (s[i] == 'D')
  28.             coorX++;
  29.         if (s[i] == 'U')
  30.             coorX--;
  31.     }
  32.     matr[coorX][coorY] = '*';
  33.  
  34.     for (int i = 0; i < n; i++)
  35.     {
  36.         for (int j = 0; j < m; j++)
  37.             cout << matr[i][j];
  38.         cout << endl;
  39.     }
  40.  
  41.     return 0;
  42. }
  43.  
  44.  
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement