Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- public class SoftUni {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String line1 = "";
- String line2 = "";
- System.out.print("Enter the number of lines here: ");
- int lines = Integer.parseInt(sc.nextLine());
- for(int i = 0;i<lines;i++){
- String[] line = sc.nextLine().split(" ");
- int[] arr = Arrays.stream(line).mapToInt(e -> Integer.parseInt(e)).toArray();
- if(i % 2 == 0){
- line1 += arr[0] + " ";
- line2 += arr[1] + " ";
- }
- else{
- line1 += arr[1] + " ";
- line2 += arr[0] + " ";
- }
- }
- System.out.println(line1);
- System.out.println(line2);
- }
- }
Add Comment
Please, Sign In to add comment