-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.java
More file actions
29 lines (27 loc) · 792 Bytes
/
example.java
File metadata and controls
29 lines (27 loc) · 792 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
import java.util.*;
public class example {
public static void main(String[] args) {
ArrayList<Integer> a = new ArrayList<>();
Random r = new Random();
for (int i = 1; i <= 10; i++) {
a.add(r.nextInt(10 - 5) + 5);
}
for (int x : a) {
System.out.print(x);
}
Set<Integer> set = new HashSet<>();
while (true) {
int j = r.nextInt(9 - 5) + 5;
System.out.println(j);
if (!set.contains(j)) {
set.add(j);
if (a.get(j) == 9) {
System.out.println("Found");
System.exit(0);
} else {
System.out.println("Not Found");
}
}
}
}
}