3518 int arr[100][100] = {};
3533 const int next_y = y - 1;
3534 if(arr[x][next_y] != 0 || next_y < 0) {
3536 dir = (dir + 1) % 4;
3544 const int next_x = x + 1;
3545 if(arr[next_x][y] != 0 || next_x >= n) {
3546 dir = (dir + 1) % 4;
3554 const int next_y = y + 1;
3555 if(arr[x][next_y] != 0 || next_y >= m) {
3556 dir = (dir + 1) % 4;
3564 const int next_x = x - 1;
3565 if(arr[next_x][y] != 0 || next_x < 0) {
3566 dir = (dir + 1) % 4;
3574 for(
int i = 0; i < n; i++) {
3575 for(
int j = 0; j < m; j++) {
3576 cout << arr[i][j] <<
" ";