应届生笔试模板
输入输出
输入:
2 ——————两行
70
hgfgfaada653234xx2de
7
dd3c2ef
int num = sc.nextInt();
for (int i = 0; i < num; i++) {
int len = sc.nextInt();
sc.nextLine();
String str = sc.nextLine();
System.out.println(test(str,len));
}
String n = sc.nextLine();
int len = Integer.parseInt(n);
for (int i = 0; i < len; i++) {
String m = sc.nextLine();
int len_1 = Integer.parseInt(m);
String str = sc.nextLine();
System.out.println(test(str,len_1));
}
数组到中括号的输入
按括号
[[5,2],[4,3],[2,1],[3,2]]进行输入
二维数组排序
数组到一个中括号的输入
/**
* 放置非法的输入符号问题
* 输入的是 [1,2,3,4,5],[5,6,7,8,9]
*/
private static void IO1() {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine().trim();
String ans = "";
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == ']' || str.charAt(i) == '[') {
continue;
}
ans += str.charAt(i);
}
String[] split = ans.split(",");
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
for (int i = 0; i < split.length / 2; i++) {
list1.add(Integer.valueOf(split[i]));
}
for (int i = split.length / 2; i < split.length; i++) {
list2.add(Integer.valueOf(split[i]));
}
System.out.println(list1.toString());
System.out.println(list2.toString());
}