Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n, m, q, x, y;
- cin >> n >> m >> q >> x >> y;
- int a[105][105] = {};
- int dx[4] = {0, 1, 0, -1};
- int dy[4] = {1, 0, -1, 0};
- int z = 0;
- for(int i=1; i<=q; i++)
- {
- int t;
- cin >> t;
- if(t == 1)
- {
- x += dx[z];
- y += dy[z];
- }
- if(t == 2)
- {
- z += 1;
- if(z == 4)
- {
- z = 0;
- }
- }
- if(x < 0 || x >= n || y < 0 || y >= m)
- {
- x -= dx[z];
- y -= dy[z];
- }
- else
- {
- a[x][y] = i;
- }
- }
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<m; j++)
- cout << a[i][j] << " ";
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment