Advertisement
CR7CR7

TopIntegers

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