diff --git a/实验.cpp b/实验.cpp new file mode 100644 index 0000000..0a753ed --- /dev/null +++ b/实验.cpp @@ -0,0 +1,131 @@ +#include +#include +int l=0; + void x1(int m[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("|"); + printf("%d",m[i][j]); + } + printf("|\n"); + } + printf("-------------"); +} + + + + +void hang(int m[9][9], int *l) { + int i,j,k; + for(i=0;i<9;i++) + { + for(j=0;j<9;j++) + { + int a=m[i][j]; + for(k=0;k<9;k++) + { + if(m[i][j]==m[i][k]&&j!=k&&a!=0) + { + printf("The number %d in the %d row has been used!\n", a, i+1); + (*l)++; + break; + } + } + if(*l==1)break; + } + if(*l==1){ + break; + } + } + +} + +void lie(int m[9][9], int *l) { + int i,j,k; + for(i=0;i<9;i++) + { + for(j=0;j<9;j++) + { + int a=m[j][i]; + for(k=0;k<9;k++) + { + if(m[j][i]==m[k][i]&&j!=k&&a!=0&&*l==0) + { + if(*l==1)break; + printf("The number %d in the %d col has been used!\n", a, i+1); + (*l)++; + break; + } + } + if(*l==1)break; + } + if(*l==1){ + break; + } + } +} +void o3(int m[9][9], int *l) { + int i,j,k,n,t; + for(n=0;n<9;n++) + { + + for(i=n%3*3;i=1) { + printf("False: Invalid initial Sudoku matrix!\n"); + } + if (l==0) { + printf("True: Valid initial Sudoku matrix!\n"); + } + + return 0; +}