我一直在試圖編寫一個可以解決數獨的程序。它不工作,但(但),我不知道爲什麼。完整的代碼是here。C++函數不會調用
多數民衆贊成給我的麻煩釷部分是這樣的:
int eliminate_3x3(){
for(int top =0; top>9; top+=3){
std::cout << "eliminate 3x3 is function properly" << std::endl;
//Based on the previous line, I'd expect to see that message pop up 3 times every time 'main'
//calls this function, but it is never shown.
for(int left =0; left>9; left+=3){
for(int column =0; column > 3; column++){
for(int row=0; row > 3; row++){
int current_value = MyArray[top+column][left+row];
std::cout << current_value << std::endl;
if(current_value != 0){
for(int column2 =0; column2 > 3; column2++){
for(int row2 =0; row2 > 3; row2++){
possibility_array[top+column2][left+row2][current_value-1] = 0;
}
}
possibility_array[top+column][left+row][current_value-1] = current_value;
}
}
}
}
}
}
無論出於何種原因,它根本不會做的所有事情(也許它沒有被恰當地稱爲main
如果有人能告訴我爲什麼,我真的很感激它。在此先感謝。
如果我使用for循環對某些人來說是個問題,我很抱歉,我對C++還是比較陌生,而且這個解決方案似乎是最好的給我
*「或者可能它沒有被主要正確調用」*可能。但是我們不能*看到*'main()'。 –
此外,你的循環都不會做任何事情。它們都是以'>'開始的,條件應該是'<'。如果'top = 0',那麼'top> 9'將永遠不會是真的。 –
現在我覺得自己像個白癡。我改變了很多其他的東西試圖解決它,我不能相信它是如此簡單。謝謝。 –