Advertisement
damesova

Top Integers

Feb 10th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package _10_ArraysExercises;
  2.  
  3.         import java.util.Arrays;
  4.         import java.util.Scanner;
  5.  
  6. public class _05_TopIntegers {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int[] input = Arrays.stream(scanner.nextLine().split(" "))
  11.                 .mapToInt(Integer::parseInt)
  12.                 .toArray();
  13.  
  14.         for (int i = 0; i < input.length; i++) {
  15.             boolean isGrater = true;
  16.             for (int j = i + 1; j < input.length; j++) {
  17.                 if (input[i] <= input[j]) {
  18.                     isGrater = false;
  19.                     break;
  20.                 }
  21.  
  22.             }
  23.             if (isGrater) {
  24.  
  25.                 System.out.print(input[i] + " ");
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement