You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
884 B
32 lines
884 B
1 year ago
|
#include"all.h"
|
||
|
int main(){
|
||
|
clock_t st, end;
|
||
|
st=clock();
|
||
|
initRandomSeed();
|
||
|
int board[9][9] = {{5, 3, 0, 0, 7, 0, 0, 0, 0},
|
||
|
{6, 0, 0, 1, 9, 5, 0, 0, 0},
|
||
|
{0, 9, 8, 0, 0, 0, 0, 6, 0},
|
||
|
{8, 0, 0, 0, 6, 0, 0, 0, 3},
|
||
|
{4, 0, 0, 8, 0, 3, 0, 0, 1},
|
||
|
{7, 0, 0, 0, 2, 0, 0, 0, 6},
|
||
|
{0, 6, 0, 0, 0, 0, 2, 8, 0},
|
||
|
{0, 0, 0, 4, 1, 9, 0, 0, 5},
|
||
|
{0, 0, 0, 0, 8, 0, 0, 7, 9}};
|
||
|
struct Sudoku a;
|
||
|
sudokufromArray(board, &a);
|
||
|
printf("The original Sudoku matrix: \n");
|
||
|
sudokuPrint(a);
|
||
|
if(sudokuJudge(a)){
|
||
|
printf("No solution!\n");
|
||
|
return 0;
|
||
|
}
|
||
|
struct Sudoku *pres = sudokuFill(&a);
|
||
|
if(!pres){
|
||
|
printf("No solution!\n");
|
||
|
return 0;
|
||
|
}
|
||
|
printf("The solution of Sudoku matrix:\n");
|
||
|
sudokuPrint(*pres);
|
||
|
end=clock();
|
||
|
printf("dur:%ldms\n", end-st);
|
||
|
}
|