标签:
package liu0913; import java.util.Random; public class Yaohao { public static void main(String[] args) { Random ran=new Random(); int[] arr=new int[8]; for(int i=0;i<8;i++) { arr[i]=ran.nextInt(36); for(int j=0;j<i;j++) { if(arr[i]==arr[j]) { i--; } } } System.out.println(arr[0]+" "+arr[1]+" "+arr[2]+" "+arr[3]+" "+arr[4]+" "+arr[5]+" "+arr[6]+" "+arr[7]); } }
采用多种算法,模拟摇奖:从1-36中随机抽出8个不重复的数字
标签:
原文地址:http://www.cnblogs.com/liuyanzeng/p/5869553.html