EmiliaKitkarska

Zadacha2

Apr 19th, 2021
558
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 2. Сливане на списъци
  2.  
  3. import java.util.*;
  4.  
  5. public class Zadachki {
  6.     public static void getArr(List list, String[] input) {
  7.         for (int i = 0; i < input.length; i++) {
  8.             String str = input[i].replaceAll("[\\D+]", "");
  9.             String[] numbers = str.split("");
  10.             list.add(numbers);
  11.         }
  12.     }
  13.  
  14.  
  15.     public static void printResult(List<String[]> result) {
  16.         for (int ind = 0; ind < result.size(); ind++) {
  17.             for (String k : result.get(ind)) {
  18.                 System.out.print(k + " ");
  19.             }
  20.         }
  21.     }
  22.  
  23.     public static void main(String[] args) {
  24.         Scanner scan = new Scanner(System.in);
  25.  
  26.         String[] input = scan.nextLine().split("\\|");
  27.         List<String[]> list = new ArrayList<>();
  28.  
  29.         getArr(list, input);
  30.         Collections.reverse(list);
  31.         printResult(list);
  32.     }
  33. }
RAW Paste Data