BetinaUKTC

zadacha2

Mar 24th, 2021 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. ////////////////////////////////////////////ВТОРА ЗАДАЧА/////////////////////////////////////////////////////////
  2. package Prog;
  3.  
  4. import java.util.*;
  5.  
  6. public class Main {
  7. public static void getArr(List list, String[] input) {
  8. for (int i = 0; i < input.length; i++) {
  9. String str = input[i].replaceAll("[\\D+]", "");
  10. String[] numbers = str.split("");
  11. list.add(numbers);
  12. }
  13. }
  14.  
  15.  
  16. public static void printResult(List<String[]> result) {
  17. for (int ind = 0; ind < result.size(); ind++) {
  18. for (String k : result.get(ind)) {
  19. System.out.print(k + " ");
  20. }
  21. }
  22. }
  23.  
  24. public static void main(String[] args) {
  25. Scanner scan = new Scanner(System.in);
  26.  
  27. String[] input = scan.nextLine().split("\\|");
  28. List<String[]> list = new ArrayList<>();
  29.  
  30. getArr(list, input);
  31. Collections.reverse(list);
  32. printResult(list);
  33. }
  34. }
Add Comment
Please, Sign In to add comment