Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- public class Soft{
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter your array here: ");
- String[] stringArr = sc.nextLine().split(" ");
- String numbers = "";
- boolean isItBigger;
- int[] intArr = Arrays.stream(stringArr).mapToInt(e -> Integer.parseInt(e)).toArray();
- for(int i = 0;i<intArr.length-1;i++){
- isItBigger = true;
- for(int j = i + 1;j<intArr.length;j++){
- if(intArr[i] < intArr[j]){
- isItBigger = false;
- }
- }
- if(isItBigger == true){
- numbers += intArr[i] + " ";
- }
- }
- System.out.println(numbers);
- }
- }
Add Comment
Please, Sign In to add comment