Files
Java/作业/刘航宇-day42/第二题/P1098.java
T
2025-12-28 21:05:06 +08:00

25 lines
813 B
Java

import java.util.*;
public class P1098 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
List<Integer> a = new ArrayList<>();
while (in.hasNextInt()) a.add(in.nextInt());
StringBuilder first = new StringBuilder();
StringBuilder second = new StringBuilder();
boolean f = true;
for (int i = 0; i < a.size(); i++) {
if ((i & 1) == 0) {
if (!f) first.append(' ');
first.append(a.get(i));
f = false;
} else {
if (second.length() > 0) second.append(' ');
second.append(a.get(i));
}
}
System.out.println(first.toString());
System.out.println(second.toString());
in.close();
}
}