-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecursive.java
More file actions
33 lines (29 loc) · 937 Bytes
/
Recursive.java
File metadata and controls
33 lines (29 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Arrays;
public class Recursive {
static boolean isFind(int[] arr, int value) {
for (int i : arr) {
if (i == value) {
return true;
}
}
return false;
}
public static void main(String[] args) {
int[] list = {3, 7, 3, 3, 2, 9, 10, 21, 1, 33, 9, 1, 8, 8};
int[] duplicate = new int[list.length];
int startIndex = 0;
for (int i = 0; i < list.length; i++) {
for (int j = 0; j < list.length; j++) {
if (list[i] % 2 == 0) {
if ((i != j) && (list[i] == list[j])) {
if (!isFind(duplicate,list[i])){
duplicate[startIndex++] = list[i];
}
break;
}
}
}
}
System.out.println(Arrays.toString(duplicate));
}
}