Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int num = Integer.parseInt(input.nextLine());
- int swap;
- int[] arr = new int[2 * num];
- int[] first_array = new int[num];
- int[] second_array = new int[num];
- String doubles_string;
- for (int i = 0; i < num; i++) {
- doubles_string = input.nextLine();
- String doubles[] = doubles_string.split(" ");
- int[] doubles_int = Arrays.stream(doubles).mapToInt(Integer::parseInt).toArray();
- first_array[i] = doubles_int[0];
- second_array[i] = doubles_int[1];
- //String[] arr = Arrays.stream(strings.split(" ")).toArray(String[]::new);
- //int[] numbers = Arrays.stream(input.nextLine().split(" ")).mapToInt(e -> Integer.parseInt(e)).toArray();
- }
- for (int i = 0; i < num; i++) {
- if (i % 2 == 0) {
- swap = second_array[i];
- second_array[i] = first_array[i];
- first_array[i] = swap;
- }
- }
- for (int i = 0; i < num; i++) {
- System.out.print(second_array[i] + " ");
- }
- System.out.println();
- for (int i = 0; i < num; i++) {
- System.out.print(first_array[i] + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement