Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void comutare(int A[100][100], int n, int m, int i, int j)
- {
- if(A[i][j] == 0) A[i][j] = 1;
- else A[i][j] = 0;
- if(A[i - 1][j] == 0) A[i - 1][j] = 1;
- else A[i - 1][j] = 0;
- if(A[i][j - 1] == 0) A[i][j - 1] = 1;
- else A[i][j - 1] = 0;
- if(A[i - 1][j - 1] == 0) A[i - 1][j - 1] = 1;
- else A[i - 1][j - 1] = 0;
- }
- int parcurgere(int A[100][100],int n,int m)
- {
- int i,j,ok=0;
- for(i=n-1;i>=1;i--)
- for(j=m-1;j>=1;j--)
- if(A[i][j]==1)
- comutare(A,n,m,i,j);
- for(i=0;i<n;i++)
- for(j=0;j<m;j++)
- if(A[i][j]==1)
- ok=1;
- if(ok)
- return 0;
- return 1;
- }
- int main()
- {
- int A[100][100];
- int n, m, x, y;
- cin >> n >> m;
- for(x = 0; x < n; x++)
- for(y = 0; y < m; y++)
- cin >> A[x][y];
- cout<<parcurgere(A,n,m)<<"\n";
- for(x = 0; x < n; x++)
- {
- for(y = 0; y < m; y++)
- cout << A[x][y];
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement