package ex2;
import java.util.Scanner;
public class DistinctNumbers {
static final int SIZE = 10;
static int[] numbers = new int[SIZE];
static int[] distinct = new int[SIZE];
public static void main(String[] args) {
int disNumCount =0;
readNumbers();
for (int i = 0; i < numbers.length; i++) {
int num = numbers[i];
for (int x = 0; x < distinct.length; x++) {
if (num == distinct[x]){
System.out.println("found a number already entered " + num);
break;
}
else
System.out.println("found a new distinct number!!");
distinct[disNumCount] = num;
disNumCount++;
break;
}
}
System.out.println("Numbers Entered :");
for (int i = 0; i < SIZE; i++) {
System.out.print(numbers[i] + " ");
}
System.out.println();
System.out.println("Distinct Numbers : ");
for (int i = 0; i < SIZE; i++) {
System.out.print(distinct[i] + " ");
}
}
private static void readNumbers() {
Scanner sin = new Scanner(System.in);
System.out.println("Enter" + SIZE + " numbers : ");
for (int i = 0; i < numbers.length; i++) {
numbers[i] = sin.nextInt();
}
}
}