Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. package com.company;
  2.  
  3. import javafx.fxml.FXMLLoader;
  4. import org.w3c.dom.ls.LSOutput;
  5.  
  6. import java.io.IOException;
  7. import java.util.Arrays;
  8. import java.util.Scanner;
  9.  
  10. public class Main {
  11.  
  12. public static void main(String[] args) throws IOException {
  13. Scanner scanner = new Scanner(System.in);
  14. int n = Integer.parseInt(scanner.nextLine());
  15. int [] firstArray = new int[n];
  16. int [] secondArray = new int[n];
  17.  
  18.  
  19.  
  20. for (int i = 1; i <=n ; i++)
  21. {
  22. int[] input = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(e->Integer.parseInt(e)).toArray();
  23. if (i % 2 ==0)
  24. {
  25. firstArray[i-1] = input[0];
  26. secondArray[i-1]= input[1];
  27. }
  28. else
  29. {
  30. firstArray[i-1] = input[1];
  31. secondArray[i-1]= input[0];
  32. }
  33. }
  34.  
  35. System.out.println(Arrays.toString(secondArray));
  36. System.out.println(Arrays.toString(firstArray));
  37.  
  38.  
  39.  
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement