Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void comutare(int A[100][100], int n, int m, int i, int j)
  6. {
  7. if(A[i][j] == 0) A[i][j] = 1;
  8. else A[i][j] = 0;
  9.  
  10. if(A[i - 1][j] == 0) A[i - 1][j] = 1;
  11. else A[i - 1][j] = 0;
  12.  
  13. if(A[i][j - 1] == 0) A[i][j - 1] = 1;
  14. else A[i][j - 1] = 0;
  15.  
  16. if(A[i - 1][j - 1] == 0) A[i - 1][j - 1] = 1;
  17. else A[i - 1][j - 1] = 0;
  18. }
  19.  
  20. int parcurgere(int A[100][100],int n,int m)
  21. {
  22. int i,j,ok=0;
  23. for(i=n-1;i>=1;i--)
  24. for(j=m-1;j>=1;j--)
  25. if(A[i][j]==1)
  26. comutare(A,n,m,i,j);
  27.  
  28. for(i=0;i<n;i++)
  29. for(j=0;j<m;j++)
  30. if(A[i][j]==1)
  31. ok=1;
  32. if(ok)
  33. return 0;
  34. return 1;
  35. }
  36.  
  37. int main()
  38. {
  39. int A[100][100];
  40. int n, m, x, y;
  41. cin >> n >> m;
  42. for(x = 0; x < n; x++)
  43. for(y = 0; y < m; y++)
  44. cin >> A[x][y];
  45. cout<<parcurgere(A,n,m)<<"\n";
  46. for(x = 0; x < n; x++)
  47. {
  48. for(y = 0; y < m; y++)
  49. cout << A[x][y];
  50. cout << "\n";
  51. }
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement