我正在编写一个数独求解器,我的老师建议我使用 3d 数组,因为我从未使用过 3d 数组;我无法弄清楚如何创建一个循环来遍历行和一个遍历列。你会怎么做呢?
编辑:我想出了如何遍历每第三列/行,希望我最终应该能够完成其他六列,但我是否朝着正确的方向前进?
int[][][] = board[9][3][3];
public boolean columnCheck(int[][][] board)
{
boolean filled = false;
for(int i = 0; i < board.length; i++)
{
for(int j = 0; j < board[0].length; j++)
{
System.out.println(board[i][j][0]);
}
}
return true;
}
public boolean rowCheck(int[][][] board)
{
boolean filled = false;
for(int i = 0; i < board.length; i++)
{
for(int j = 0; j < board[0].length; j++)
{
System.out.println(board[i][0][j]);
}
}
return true;
Run Code Online (Sandbox Code Playgroud)