Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import javafx.fxml.FXMLLoader;
- import org.w3c.dom.ls.LSOutput;
- import java.io.IOException;
- import java.util.Arrays;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws IOException {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int [] firstArray = new int[n];
- int [] secondArray = new int[n];
- for (int i = 1; i <=n ; i++)
- {
- int[] input = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(e->Integer.parseInt(e)).toArray();
- if (i % 2 ==0)
- {
- firstArray[i-1] = input[0];
- secondArray[i-1]= input[1];
- }
- else
- {
- firstArray[i-1] = input[1];
- secondArray[i-1]= input[0];
- }
- }
- System.out.println(Arrays.toString(secondArray));
- System.out.println(Arrays.toString(firstArray));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement