我的indexoutofbounds問題已解決,但不是我的程序編譯,但打印出一個未改變的難題..不知道我要去哪裏錯了?最初的拼圖讀取ROM標準輸入在0數獨拼圖的'空'單元的地方。我也包括了我的數據列表初始化程序。java數獨解算器值不變
public ArrayList<Integer> create(){
ArrayList<Integer> possible = new ArrayList<Integer>();
for(int i=1; i<10; i++){
possible.add(i);
}
return possible;
}
public sudoku(int size)
{
SIZE = size;
N = size*size;
Grid = new int[N][N];
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
Grid[i][j] = 0;
}
public void solve()
{
int a, b, c, d, i, j, k, l;
int count = 0;
int value= 0;
for(i=0; i<N;i++){
for(j=0; j<N;j++){
if(Grid[i][j]==0){
ArrayList<Integer> possible = create();
//check row
for(a=0; a<N;a++){
for(b=0; b<N; b++){
if(Grid[a][0]==possible.get(a)){
possible.set(a, 0);
}
}
}
//check column
for(c=0; c<N;c++){
for(d=0; d<N;d++){
if(Grid[0][d]==possible.get(d)){
possible.set(d,0);
}
}
}
for(k=0; k<9; k++){
if(possible.get(k)!=0){
count++;
}
}
if(count==1){
for(l=0; l<9; l++){
if(possible.get(l)!=0){
value=possible.get(l);
}
}
}
Grid[i][j]=value;
}
}
}
}
我們看不到初始化網格大小的位置,所以幫助您更加困難。 (或者可能不可能幫到你) – 2012-04-15 03:52:09
我並不是真正興奮的_Grid [我] [0] _,我看到了幾次......這不是你的問題......但。 – 2012-04-15 03:52:49
哪條線路不通? – 2012-04-15 03:54:03