Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ZigZagArrays {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- String[] first = new String[n];
- String[] second = new String[n];
- for (int i = 1; i <= n; i++) {
- String[] input = scanner.nextLine().split(" ");
- if (i % 2 == 0) {
- first[i - 1] = input[1];
- second[i - 1] = input[0];
- } else {
- first[i - 1] = input[0];
- second[i - 1] = input[1];
- }
- }
- System.out.println(String.join(" ", first));
- System.out.println(String.join(" ", second));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement