을 반환하지 않습니다 내가 스도쿠 알고리즘으로 붙어 조금, 내가 그것을 철수 사용하고이 작업을해야 theorical 단계에 따라 구분하고, 내가 그것을 debuge하려고했으나 하드 너무 해요 (어디에 문제가 그래, 그것은) 내가 코드를 붙여스도쿠 알고리즘은 모든 솔루션
을 몇 가지 숫자를 해결하고 일을, 난 희망 당신이 나를 도울 수, 난 정말 내가 ommited
public void backtracking(int row,int col){
if(row > 8){
System.out.println("Solution Found!!");
printSudoku();
}
if (m[row][col] != 0){
next(row, col);
}
else {
for(int i =1; i < n;i++)
if(row(row, i) && col(col, i)) {
m[row][col] =i;
next(row, col);
}
m[row][col] = 0;
}
}
public void next(int row, int col) {
if(col < 8)
backtracking(row, col + 1) ;
else
backtracking(row+ 1, 0) ;
}
public boolean region(int x, int y, int numReg) {
x = (x/3) * 3 ;
y = (y/3) * 3 ;
for(int r = 0; r < 3; r++)
for(int c = 0; c < 3; c++)
if(m[x+r][y+c] == numReg)
return false ;
return true ;
}
public boolean row(int x, int k){
for(int i =0; i < 9; i++)
if(m[x][i] == k)
return false;
return true;
}
public boolean col(int x, int k){
for(int i =0; i < 9; i++)
if(m[i][x] == k)
return false;
return true;
}
... 볼 수 없습니다 "printSudoku"메쏘드는 단지 두 배에 불과합니다.
을 이미 즉, 역 추적 및 스도쿠 대한 questiions를 읽었다 : [이 질문] (http://stackoverflow.com/questions/9959172/recursive-solution- 투 스도쿠 발전기? 심지어 [(http://stackoverflow.com/questions/9404673/sudoku-solver-in-java-using-backtracking-and-recursion?rq=1)) = 1 RQ [또는 이와] 이 하나] (http://stackoverflow.com/questions/6432794/why-is-this-sudoku-backtracking-getting-stuck?rq=1) – icrovett
은 내가했고, 질문하는 것이 내 솔루션을 기반으로하지만, 아무튼 '일하지 마라. 나는 단지 재미만을 묻지 않는다. S – Santanor