From 7c6a26258bd7deb651858ef42cbe7db2da2601cf Mon Sep 17 00:00:00 2001 From: pngtmzsyq <864002285@qq.com> Date: Sat, 4 Nov 2023 18:51:37 +0800 Subject: [PATCH] =?UTF-8?q?Delete=20'=E5=88=A4=E6=96=AD=E9=9A=8F=E6=9C=BA.?= =?UTF-8?q?c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 判断随机.c | 69 -------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 判断随机.c diff --git a/判断随机.c b/判断随机.c deleted file mode 100644 index 89b7a05..0000000 --- a/判断随机.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -void correct(int board[9][9]){ - int col[9]={0},row[9]={0},block[9]={0}; - int i,j; - for(i=0;i<9;++i){ - for(j=0;j<9;j++){ - int index=1<<(board[i][j]-1); - int blockindex=i/3*3+j/3; - if(board[i][j]!=0){ - if(row[i]&index){ - printf("False:Invalid initial Sudoku matrix!\n"); - printf("The number %d in the row %d has been used!",board[i][j],i+1); - return 0; - } - row[i]=index; - if(col[j]&index){ - printf("False:Invalid initial Sudoku matrix!\n"); - printf("The number %d in the rol %d has been used!",board[i][j],j+1); - return 0; - } - col[j]=index; - if(block[blockindex]&index){ - printf("False:Invalid initial Sudoku matrix!\n"); - printf("The number %d in the block %d has been used!",board[i][j],blockindex+1); - return 0; - } - block[blockindex]=index; - } - printf("True:Valid initial Sudoku matrix!\n"); - return 1; - - } - } - -} -void print(int board[9][9]){ - printf("|---|---|---|---|---|---|\n"); - int i=0,j=0,s=0,k=0; - for(i=0;i<9;++i){ - for(j=0;j<9;j++){ - while(j%3==0){ - printf("| "); - break; - } - printf("%d ",board[i][j]); - } - printf("|\n"); - while((i+1)%3==0){ - printf("|---|---|---|---|---|---|\n"); - break; - } - } -} -int main(){ - int board1[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}}; - printf("The original Sudoku matrix:\n"); - print(board1); - correct(board1[9][9]); - - return 0; -}