构建数独游戏。如果他们决定使用列而不是行输入数据,我如何使用用户输入更新我的二维数组?我不明白为什么它不能正常工作?
else if (dataSelection == 2) {
if (boardSize == 1) {
int column = 1;
int column2 = 0;
while (column < 4) {
Scanner firstColumn4x4 = new Scanner(System.in);
System.out.println("Please enter four values using commas for column " + column);
String column1Values4x4 = firstColumn4x4.next();
String strArray[] = column1Values4x4.split(",");
int arraySidesInteger[] = new int[strArray.length];
for (int i = 0; i < strArray.length; i++) {
arraySidesInteger[i] = Integer.parseInt(strArray[i]);
}
***fourArray[column-1][column2] = arraySidesInteger[column2];*** //can not figure out thisstatement
for (int i = 0; i < fourArray.length; i++)
{
for (int j = 0; j < fourArray.length; j++)
System.out.print(fourArray[i][j] + " ");
System.out.println();
}
column++;
column2++;
}
如果用户为第 1 列输入 1、2、3、4,我希望它打印出来: 1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0
但是我不断得到:1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
谢谢!