1 //产生随机数, 彩票自动生成系统 2 Random num = new Random(); 3 int b,c; 4 int[] arr1 = new int[6]; 5 for(int i=1;i<=6;i++) { 6 int j = 1; 7 int a = num.nextInt(32)+1; 8 arr1[i-1] = a; 9 if(i!=1) { 10 while(j<i) { 11 b = arr1[i-1]-arr1[i-j-1]; 12 j++; 13 if(b==0) { 14 i=1; 15 break; 16 } 17 } 18 } 19 } 20 Arrays.sort(arr1); 21 System.out.print("红球为:"); 22 for(int i=1;i<=6;i++) { 23 System.out.print(arr1[i-1]+"; "); 24 } 25 System.out.println(); 26 c = num.nextInt(15)+1; 27 System.out.println("蓝球为:"+c);
原文:http://www.cnblogs.com/wgbs25673578/p/5040525.html