1 int a[] = new int[6];
//随机六个数 2 for (int i = 0; i < a.length; i++) { 3 int v = (int) (Math.random() * 32 + 1); 4 a[i] = v;
//使随机数不重复 5 for(int j = 0;j<i;j++){ 6 if(a[i]==a[j]) 7 v = (int)(Math.random()* 32 + 1); 8 a[i]=v; 9 } 10 System.out.print(a[i] + " "); 11 } 12 System.out.println(); 13
//排序 14 for (int j = 0; j < a.length - 1; j++) { 15 for (int i = j + 1; i < a.length; i++) { 16 if (a[i] < a[j]) { 17 int temp = a[j]; 18 a[j] = a[i]; 19 a[i] = temp; 20 } 21 } 22 } 23 System.out.print("red ");
随机一个蓝球 24 for (int i = 0; i < a.length; i++) { 25 System.out.print(a[i] + " "); 26 } 27 int blu = (int) (Math.random()*15+1); 28 System.out.print("blu "+blu); 29 }
标签:双色球,int,blu,System,++,length,out From: https://www.cnblogs.com/hhxz/p/17213335.html