Advertisement
deyanmalinov

05. Reverse And Exclude

Apr 22nd, 2020
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.List;
  3. import java.util.Scanner;
  4. import java.util.stream.Collectors;
  5.  
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         List<Integer> nums = Arrays.stream(scan.nextLine().split("\\s+"))
  10.                 .map(Integer::parseInt)
  11.                 .collect(Collectors.toList());
  12.         int dev = Integer.parseInt(scan.nextLine());
  13.         nums.stream()
  14.                 .filter(num -> num % dev != 0)
  15.                 .sorted((x,y)-> -1)
  16.                 .forEach(num -> System.out.print(num + " "));
  17.  
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement