fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <iomanip>
  4. #include <ctime>
  5. using namespace std;
  6. int random(int a, int b)
  7. {
  8. return a+rand()%(b-a+1);
  9. }
  10. int main()
  11. {
  12. const int N=6;
  13. int A[N][N], i, j, t=1, k=0;
  14. srand(time(NULL));
  15. for(i=0;i<N;i++)
  16. {
  17. for(j=0;j<N;j++)
  18. {
  19. A[i][j]=random(0,1);
  20. cout<<setw(2);
  21. cout<<A[i][j];
  22. }
  23. cout<<endl;
  24. }
  25. cout<<endl;
  26. for(i=0;i<N;i++)
  27. {
  28. t=1;
  29. for(j=0;j<N;j++)
  30. {
  31. m:
  32. if(A[i][j]==A[i+t][j] || A[i][j]==A[i-t][j]|| A[i][j]==A[i][j+t]||A[i][j]==A[i][j-t])
  33. {
  34. t++;
  35. goto m;
  36. }
  37. else
  38. {
  39. k++;
  40. break;
  41. }
  42. }
  43. }
  44. cout<<k;
  45. cin.get();
  46. cin.get();
  47. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 1 0 0 0 0
 1 0 0 1 0 0
 0 0 1 0 0 1
 0 0 1 0 1 1

6