Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
909 B
1
Indexable
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        {
            Scanner input = new Scanner(System.in);
            Integer[] numbers = new Integer[5];
            for (int i = 0; i < 5; i++) {
                System.out.println("Enter " + i + " :");
                numbers[i] = input.nextInt();
            }
            Arrays.sort(numbers);
            for (int i = 0; i < numbers.length; i++) {
                for (int j = i + 1; j < numbers.length; j++) {
                    if (numbers[i] == numbers[j]) {
                        numbers[j] = Integer.MAX_VALUE;
                    }
                }

            }
            for (int i = 0; i < numbers.length; i++) {
                if(numbers[i]< Integer.MAX_VALUE) System.out.print(numbers[i]+" ");

            }
        }
    }


}