djelad1

Untitled

Dec 2nd, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. int matrix[SIZE2][SIZE2] ={
  2. { 1, 1, 0, 1, 1 },
  3. { 1, 0, 1, 0, 1 },
  4. { 0, 1, 1, 1, 0 },
  5. { 1, 0, 1, 0, 1 },
  6. { 1, 1, 0, 1, 1 } };
  7.  
  8. int mask[SIZE2][SIZE2] = { 0 };
  9. bool flag = true;
  10. int j = 0, i = 0;
  11. for (i = ((SIZE2 - 1) / 2); i >= 0; i--)
  12. {
  13. mask[i][j++] = 1;
  14. }
  15.  
  16. for (i = 0, j = (SIZE2 % 2 == 0 ? SIZE2 / 2 : (SIZE2 - 1) / 2); i <= (SIZE2 / 2) - 1; i++)
  17. {
  18. mask[i][j++] = 1;
  19. }
  20.  
  21. for (j = SIZE2 - 1, i = (SIZE2 % 2 == 0 ? SIZE2 / 2 : (SIZE2 - 1) / 2); i < SIZE2; i++, j--)
  22. {
  23. mask[i][j] = 1;
  24. }
  25.  
  26. for (j = (SIZE2 % 2 == 0 ? (SIZE2 / 2 - 1) : SIZE2 / 2), i = SIZE2 - 1; i >= SIZE2 / 2; i--, j--)
  27. {
  28. mask[i][j] = 1;
  29. }
  30. cout << "original diamond: \n";
  31. for (i = 0; i < SIZE2; i++)
  32. {
  33. for (j = 0; j < SIZE2; j++)
  34. cout << (mask[i][j] ? "0 " : " ");
  35. cout << endl;
  36. }
  37. cout << "your matrix : \n";
  38. for (i = 0; i < SIZE2; i++)
  39. {
  40. for (j = 0; j < SIZE2; j++)
  41. cout << (matrix[i][j] ? " " : "0 ");
  42. cout << endl;
  43. }
  44. for (i = 0; i < SIZE2; i++)
  45. {
  46. for (j = 0; j < SIZE2; j++)
  47. if (mask[i][j] == 1 && matrix[i][j] != 0)
  48. flag = false;
  49. }
  50. cout << (flag ? "\nCompatible Diamond\n" : "INVALID Diamond") << endl;
  51. break;
  52. system("pause");
  53. system("cls");
Advertisement
Add Comment
Please, Sign In to add comment