Update fill.c

main
po79yr3at 1 year ago
parent d77cf1f666
commit c0d2316ed4

@ -1,32 +1,32 @@
#include"all.h" #include"all.h"
int main(){ int main(){
clock_t st, end; clock_t st, end;
st=clock(); st=clock();
initRandomSeed(); initRandomSeed();
int board[9][9] = {{5, 3, 0, 0, 7, 0, 0, 0, 0}, int board[9][9] = {{5, 3, 0, 0, 7, 0, 0, 0, 0},
{6, 0, 0, 1, 9, 5, 0, 0, 0}, {6, 0, 0, 1, 9, 5, 0, 0, 0},
{0, 9, 8, 0, 0, 0, 0, 6, 0}, {0, 9, 8, 0, 0, 0, 0, 6, 0},
{8, 0, 0, 0, 6, 0, 0, 0, 3}, {8, 0, 0, 0, 6, 0, 0, 0, 3},
{4, 0, 0, 8, 0, 3, 0, 0, 1}, {4, 0, 0, 8, 0, 3, 0, 0, 1},
{7, 0, 0, 0, 2, 0, 0, 0, 6}, {7, 0, 0, 0, 2, 0, 0, 0, 6},
{0, 6, 0, 0, 0, 0, 2, 8, 0}, {0, 6, 0, 0, 0, 0, 2, 8, 0},
{0, 0, 0, 4, 1, 9, 0, 0, 5}, {0, 0, 0, 4, 1, 9, 0, 0, 5},
{0, 0, 0, 0, 8, 0, 0, 7, 9}}; {0, 0, 0, 0, 8, 0, 0, 7, 9}};
struct Sudoku a; struct Sudoku a;
sudokufromArray(board, &a); sudokufromArray(board, &a);
printf("The original Sudoku matrix: \n"); printf("The original Sudoku matrix: \n");
sudokuPrint(a); sudokuPrint(a);
if(sudokuJudge(a)){ if(sudokuJudge(a)){
printf("No solution!\n"); printf("No solution!\n");
return 0; return 0;
} }
struct Sudoku *pres = sudokuFill(&a); struct Sudoku *pres = sudokuFill(&a);
if(!pres){ if(!pres){
printf("No solution!\n"); printf("No solution!\n");
return 0; return 0;
} }
printf("The solution of Sudoku matrix:\n"); printf("The solution of Sudoku matrix:\n");
sudokuPrint(*pres); sudokuPrint(*pres);
end=clock(); end=clock();
printf("dur:%ldms\n", end-st); printf("dur:%.1lfms\n", ((double)end-st)/CLOCKS_PER_SEC*1000);
} }
Loading…
Cancel
Save