parent
d77cf1f666
commit
c0d2316ed4
@ -1,32 +1,32 @@
|
||||
#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);
|
||||
#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:%.1lfms\n", ((double)end-st)/CLOCKS_PER_SEC*1000);
|
||||
}
|
Loading…
Reference in new issue