日期:2014-05-20 浏览次数:20951 次
/* * num为0到100 即表示0%-100%
*/ public static Boolean probability(int num) {
int flag = random.nextInt(100) +1 ;
if (flag <= num) return true;
return false;
}
//递归
public static int recursion(int flag,int nature){
if(probability(flag)){
nature+=1;
System.out.println("nature="+nature);
recursion(flag,nature);
}
return nature;
}
public static void main(String[] args) {
System.out.println(recursion(50,0));
}