67,515
社区成员
发帖
与我相关
我的任务
分享
static int[][] arr = {{10, 10}, {30, 20}, {80, 50}, {180, 100}, {480, 300}, {980, 500}, {99999999, 99999999}};
static String[] desc = {"特等奖", "一等奖", "3等奖", "4等奖", "5等奖", "6等奖", "7等奖" };
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i = 1000;
while(i-- > 0){
comeOn((int)(Math.random() * 500000 + 1));
}
}
public static void comeOn(int random){
for(int i = 0; i < arr.length; i++){
if(random <= arr[i][0]){
if(arr[i][1] > 0){
arr[i][1] = arr[i][1] - 1;
System.out.println(desc[i]);
return;
}else {
System.out.println(desc[desc.length - 1]);
}
}
}
}