import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
public class Dog {
public static void main(String[] args) {
Random rand = new Random();
Set<Integer> set = new TreeSet<Integer>();
while(set.size() < 99){
int value = rand.nextInt(101);
if(value > 0){
set.add(value);
}
}
for(int i = 1; i <= 100; i++){
if(!set.contains(i)){
System.out.println("Digit between 1 and 100 not in the set: " + i);
}
}
}
}
--------------
Digit between 1 and 100 not in the set: 10
温馨提示:答案为网友推荐,仅供参考