java 数独(性质求简单代码)

2024-12-18 19:55:20
推荐回答(1个)
回答1:

这只是一个找规律的题而已,找好规律了,谁都会做。

import java.util.Arrays;
import java.util.Scanner;
public class Kuaile {
public static void main(String[] args) {
System.out.println("请输入一个>=34的数:");
Scanner in = new Scanner(System.in);
int num = in.nextInt();
while (num < 34) {
System.out.println("数值太小了!请重输:");
num = in.nextInt();
}
int row1[] = { 8, 11, num - 20, 1 };
int row2[] = { num - 21, 2, 7, 12 };
int row3[] = { 3, num - 18, 9, 6 };
int row4[] = { 10, 5, 4, num - 19 };
System.out.println(Arrays.toString(row1));
System.out.println(Arrays.toString(row2));
System.out.println(Arrays.toString(row3));
System.out.println(Arrays.toString(row4));
}
}