Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- import java.util.stream.Collectors;
- //TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
- // click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String[] numbers = scan.nextLine().split("\\s*\\|\\s*");
- int tempBrI = 0;
- List<String> sorted = new ArrayList<>();
- int numSize = numbers.length;
- for(int i = numSize - 1; i >= 0; i--) {
- if(numbers[i].equals("|")) {
- sorted.add("");
- }
- else{
- sorted.add(String.valueOf(numbers[i]));
- }
- }
- for (int i = 0; i < sorted.size(); i++) {
- System.out.print(sorted.get(i) + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement