解题思路创建容器
注意事项:一定要用nextline()这个函数一次性读取一行
参考代码:
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String rows1 = sc.nextLine();
String rows2 = sc.nextLine();
String[] s1 = rows1.split(" ");
int[]arr1 = new int[s1.length];
String[] s2 = rows2.split(" ");
int[]arr2 = new int[s2.length];
for (int i = 0; i < s1.length; i++) {
arr1[i]=Integer.parseInt(s1[i]);
}
for (int i = 0; i < s2.length; i++) {
arr2[i]=Integer.parseInt(s2[i]);
}
for (int i = 0; i < s1.length; i++) {
System.out.print((char) arr1[i]);
}
for (int i = 0; i < s2.length; i++) {
System.out.print((char) arr2[i]);
}
}
}
0.0分
0 人评分