class Day05_Work2 {
public static void main(String[] args) {
int[] arr = {6,2,9,6,1,2,6,7,8};
getArray(arr);
}
public static void getArray(int[] arr){
for (int a = 0;a < arr.length ;a++ ) {
for (int b = a +1; b < arr.length ;b++ ) {
if (arr[a]==arr[b]) {
arr[b] = -1;
}
}
}
for (int c = 0;c < arr.length ;c++ ) {
if (arr[c] == -1) {
continue;
} else {
System.out.print(arr[c]+" ");
}
}
}
}
|
|