// 生成3个0-1000的随机数
Random rand = new Random();
for (int i=0; i<3; i++){
int s = rand.nextInt(1000);
System.out.println(s);
}
// 抽出一个特等奖
String[] names = {
"1", "2", "3", "4", "5"
};
Random rand = new Random();
int s = rand.nextInt(5);
System.out.println(names[s]);
// 抽出3个一等奖
int[] result = new int[3];
int count = 0;
Random rand = new Random();
while (count<3){
//抽一个幸运员工,s是它的号码
int s = rand.nextInt(96);
//检查s是否中过奖了,检查s是否在result里
boolean exist = false;
for (int i= 0; i<count; i++){
if (result[i] == s){
exist = true;
break;
}
}
if (exist){
continue;
}
else{
result[count] = s;
count++;
}
}
for (int i=0; i<result.length; i++){
System.out.println(result[i]);
}