Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int check_sudoku(int sudoku[9][9])
- {
- int count[9];
- for(int i = 0; i < 9; i++)
- {
- count[i] = 0;
- }
- for(int i = 0; i < 9; i++)
- {
- for(int j = 0; j < 9; j++)
- {
- count[sudoku[i][j]] ++;
- }
- for(int j = 0; j < 9; j++)
- {
- if(count[j] > 1)
- {
- return 1;
- }
- }
- for(int i = 0; i < 9; i++)
- {
- count[i] = 0;
- }
- }
- for(int i = 0; i < 9; i++)
- {
- for(int j = 0; j < 9; j++)
- {
- count[sudoku[j][i]] ++;
- }
- for(int j = 0; j < 9; j++)
- {
- if(count[j] > 1)
- {
- return 1;
- }
- }
- for(int i = 0; i < 9; i++)
- {
- count[i] = 0;
- }
- }
- for(int i = 1; i < 8; i += 3)
- {
- for (int j = 1; j < 8; j += 3)
- {
- for(int x = -1; x < 2; x++)
- {
- for(int y = -1; y < 2; y++)
- {
- count[sudoku[i-x][j-y]]++;
- }
- }
- for(int j = 0; j < 9; j++)
- {
- if(count[j] > 1)
- {
- return 1;
- }
- }
- for(int i = 0; i < 9; i++)
- {
- count[i] = 0;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement