Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java中的数独风格程序_Java - Fatal编程技术网

java中的数独风格程序

java中的数独风格程序,java,Java,这是一个数独风格的程序,只使用“a,B,C”等。在数独中,每行或每列中不能有两个或两个以上的相同字母,但对角线中可以有两个或两个以上的相同字母。这个“数独游戏是在一个3x3的正方形里玩的”。正方形中的每个框编号为1-9[由于该框的位置] 其中一个是左上方的方框,两个是中间上方的方框。。。九是右边缘框。用户将输入一行,其中将包含游戏开始时网格中的字母数,然后是它们的位置,第一个数字将是锁定的字母数。锁定的字母是无法移动的字母 这是我的代码: import java.util.Scanner; 公

这是一个数独风格的程序,只使用“a,B,C”等。在数独中,每行或每列中不能有两个或两个以上的相同字母,但对角线中可以有两个或两个以上的相同字母。这个“数独游戏是在一个3x3的正方形里玩的”。正方形中的每个框编号为1-9[由于该框的位置] 其中一个是左上方的方框,两个是中间上方的方框。。。九是右边缘框。用户将输入一行,其中将包含游戏开始时网格中的字母数,然后是它们的位置,第一个数字将是锁定的字母数。锁定的字母是无法移动的字母

这是我的代码:

import java.util.Scanner;
公共课ABC{
公共静态void main(字符串[]args){
扫描仪S=新的扫描仪(System.in);
System.out.println(“输入:”);
字符串为=S.nextLine();
字符串[]SIS=IS.split(“,”);
int LOSIS=(SIS.length)-1;
系统输出打印项次(LOSIS);
字符串[]位置=新字符串[9];
// |_|_|_|_|_|_|_|_|_|
for(int i=1;i0;i++){
}
}

}
我清理了你的代码。Java变量以小写字母开头。我将一些短变量名更改为更长、更具描述性的名称。我把空行放在代码组中。我不知道你是否学过方法。每个代码组都应该是一个单独的方法

import java.util.Scanner;

public class ABC {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("Input:");
        String locationString = scanner.nextLine();
        String[] locationDigits = locationString.split(", ");
        int locationDigitsLength = (locationDigits.length) - 1;
        System.out.println(locationDigitsLength);
        String[] location = new String[9];

        // |_|_|_|_|_|_|_|_|_|
        for (int i = 1; i <= ((locationDigits.length) - 1) / 2; i++) {
            System.out.println("In the loop");
            int dummy = Integer.parseInt(locationDigits[i]);
            location[dummy] = locationDigits[i + 1];
            System.out.println(location[dummy]);
        }

        String[] top = { location[0], location[1], location[2] };
        String[] middle = { location[3], location[4], location[5] };
        String[] bottom = { location[6], location[7], location[8] };

        for (int i = 1; i < location.length; i++) {

        }

        scanner.close();
    }

}
import java.util.Scanner;
公共课ABC{
公共静态void main(字符串[]args){
扫描仪=新的扫描仪(System.in);
System.out.println(“输入:”);
String locationString=scanner.nextLine();
String[]locationDigits=locationString.split(“,”);
int locationDigitsLength=(locationDigits.length)-1;
System.out.println(LocationDigitLength);
字符串[]位置=新字符串[9];
// |_|_|_|_|_|_|_|_|_|

对于(int i=1;我认为这是最简单的部分,你能为你的代码的其余部分想出一个逻辑并且有问题吗???我想我能解决的一个方法是将字符串顶部、中部和底部的每个字母随机。然后检查是否没有字母匹配,然后检查随机数组是否满足输入的要求…但我不知道哦,怎么做谢谢你清理了它,但是你怎么做数独部分呢