Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int matrix[SIZE2][SIZE2] ={
- { 1, 1, 0, 1, 1 },
- { 1, 0, 1, 0, 1 },
- { 0, 1, 1, 1, 0 },
- { 1, 0, 1, 0, 1 },
- { 1, 1, 0, 1, 1 } };
- int mask[SIZE2][SIZE2] = { 0 };
- bool flag = true;
- int j = 0, i = 0;
- for (i = ((SIZE2 - 1) / 2); i >= 0; i--)
- {
- mask[i][j++] = 1;
- }
- for (i = 0, j = (SIZE2 % 2 == 0 ? SIZE2 / 2 : (SIZE2 - 1) / 2); i <= (SIZE2 / 2) - 1; i++)
- {
- mask[i][j++] = 1;
- }
- for (j = SIZE2 - 1, i = (SIZE2 % 2 == 0 ? SIZE2 / 2 : (SIZE2 - 1) / 2); i < SIZE2; i++, j--)
- {
- mask[i][j] = 1;
- }
- for (j = (SIZE2 % 2 == 0 ? (SIZE2 / 2 - 1) : SIZE2 / 2), i = SIZE2 - 1; i >= SIZE2 / 2; i--, j--)
- {
- mask[i][j] = 1;
- }
- cout << "original diamond: \n";
- for (i = 0; i < SIZE2; i++)
- {
- for (j = 0; j < SIZE2; j++)
- cout << (mask[i][j] ? "0 " : " ");
- cout << endl;
- }
- cout << "your matrix : \n";
- for (i = 0; i < SIZE2; i++)
- {
- for (j = 0; j < SIZE2; j++)
- cout << (matrix[i][j] ? " " : "0 ");
- cout << endl;
- }
- for (i = 0; i < SIZE2; i++)
- {
- for (j = 0; j < SIZE2; j++)
- if (mask[i][j] == 1 && matrix[i][j] != 0)
- flag = false;
- }
- cout << (flag ? "\nCompatible Diamond\n" : "INVALID Diamond") << endl;
- break;
- system("pause");
- system("cls");
Advertisement
Add Comment
Please, Sign In to add comment