Scanner sc = new Scanner(System.in);
String inputString = sc.nextLine();
String stringArray[] = inputString.split(" ");
int num[] = new int[stringArray.length];
for (int i = 0; i < stringArray.length; i++) {
num[i] = Integer.parseInt(stringArray[i]);
}
核心是切割字符串,将字符串里面的数字转换,存进数组