Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- int a[100][100];
- inline void Fill(int i, int j)
- {
- a[i][j] = 1;
- if(a[i+1][j]== -1)
- Fill(i + 1, j);
- if(a[i-1][j]== -1)
- Fill(i - 1, j);
- if(a[i][j+1]== -1)
- Fill(i, j + 1);
- if(a[i][j-1]== -1)
- Fill(i, j - 1);
- }
- int main()
- {
- int n, m;
- cin >> n >> m;
- for (int i = 1; i <= n; i++)
- for (int j = 1; j <= m; j++)
- a[i][j] = -1;
- Fill(1, 1);
- for (int i = 1; i <= n; i++){
- for (int j = 1; j <= m; j++)
- cout << a[i][j] << ' ';
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement