deyanmalinov

05. Reverse And Exclude

Apr 22nd, 2020
321
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data