刚用C语言写的,自己编译去吧。
#include <iostream>
#define Null 0
#define Max 100
using namespace std;
int gradation=0,*nullnum[Max],n_nullnum=0; //gradation层次,nullnum为待求数字地址,n_nullnum为待求数字个数.
int position_i[Max],position_j[Max]; //每个待求数字的下标.
int shudu[9][9]= //待求数独的数组,待求量以0表示.
{
{0,0,9, 0,4,0, 6,0,0},
{0,8,0, 0,0,0, 0,1,4},
{0,2,4, 0,6,0, 7,0,0},
{8,3,2, 5,1,9, 4,6,7},
{7,9,1, 0,2,0, 3,8,5},
{5,4,6, 7,8,3, 0,9,0},
{0,9,7, 0,3,0, 5,2,0},
{0,0,3, 0,0,2, 0,4,0},
{0,0,5, 0,9,0, 8,7,3}
};
bool line(int i,int j) //判断该尝试值在此行是否重复.
{
int cirtemp,temp=0;
for(cirtemp=0;cirtemp<9;cirtemp++)
if(shudu[i][j]==shudu[cirtemp][j])
temp++;
if(temp==1)
return true;
else
return false;
}
bool raw(int i,int j) //判断该尝试值在此列是否重复
{
int cirtemp,temp=0;
for(cirtemp=0;cirtemp<9;cirtemp++)
if(shudu[i][j]==shudu[i][cirtemp])
temp++;
if(temp==1)
return true;
else
return false;
}
bool area(int i,int j) //判断该尝试值在所在九宫格内是否重复