ADD file via upload

main
pwcut26i8 3 weeks ago
parent dc12358b42
commit e7a572ad86

@ -0,0 +1,65 @@
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
void check(){
int check,num;
int lie[9][9]={0};
int hang[9][9]={0};
int kua[9][9]={0};
printf("The original Sudoku matrix: ");
int i,j;
int board[9][9];
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
printf("%d",board[i][j]);
}
printf("\n");
}
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
num=board[i][j];
if(num<1||num>9)
check=0;
if(hang[i][num])
{
check=0;
hang[i][num]=1;}
if(lie[i][num])
{
check=0;
lie[i][num]=1;}
if(kua[(i/3)*3+j/3][num])
{
check=0;
kua[(i/3)*3+j/3][num]=1;
}
else
check=1;
}
}
if(check==1)
printf("True:Valid initial Sudoku matrix!");
else
printf("False:Invalid initial Sudoku matrix!");
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
num=board[i][j];
if(hang[i][num])
printf("The number %d in the hang %d has been
used!"num,i);
if(lie[i][num])
printf("The number %d in the lie %d has been
used!"num,i);
if(hua[(i/3)*3+j/3][num])
printf("The number %d in the kua %d has been
used!"num,(i/3)*3+j/3);
}
}
}
Loading…
Cancel
Save