#include #include struct Checkout{ int flag; char type[20]; int num; int place; }; void printmat(volatile int board[9][9]) { int i,j; for (i=0;i<9;i++) { if(i%3==0) printf("|-----------------------|\n"); for(j=0;j<9;j++) { if(j%3==0) printf(j==0?"|":" |"); printf(" %d",board[i][j]); } printf(" |\n"); } printf("|-----------------------|\n"); return; } struct Checkout check(volatile int board[9][9]) { int checkmat[9][2][2]={{{0,0},{3,3}}, {{0,3},{3,6}}, {{0,6},{3,9}}, {{3,0},{6,3}}, {{3,3},{6,6}}, {{3,6},{6,9}}, {{6,0},{9,3}}, {{6,3},{9,6}}, {{6,6},{9,9}}}; int i,j,k; struct Checkout out; for (i=0;i<9;i++) { int flag[9] = {0,0,0,0,0,0,0,0,0}; for (j=0;j<9;j++) { if (board[i][j]!=0 ) { if (flag[board[i][j]-1]==1) { //printf("False:Invalid initial Sudoku matrix\n"); //printf(" The number %d in the row %d has been used!\n",board[i][j],i+1); out.flag=0; strcpy(out.type,"row"); out.num=board[i][j]; out.place=i+1; return out; } else flag[board[i][j]-1]=1; } } } for (i=0;i<9;i++) { int flag[9] = {0,0,0,0,0,0,0,0,0}; for (j=0;j<9;j++) { if (board[j][i]!=0 ) { if (flag[board[j][i]-1]==1) { //printf("False:Invalid initial Sudoku matrix\n"); //printf(" The number %d in the col %d has been used!\n",board[j][i],i+1); out.flag=0; strcpy(out.type,"col"); out.num=board[j][i]; out.place=i+1; return out; } else flag[board[j][i]-1]=1; } } } for (k=0;k<9;k++) { int flag[9] = {0,0,0,0,0,0,0,0,0}; for (i=checkmat[k][0][0];i