public
class
test
{
public
static
void
main(String[]
args)
{
int[]
a
=
new
int[36]
for(int
i
=
0
i
<
36
++i)
a[i]
=
i+1
for(int
i
=
0
i
<
5
++i)
randomSelect(a,
7)
}
static
void
randomSelect(int[]
a,
int
n)
{
randomShuffle(a,
7)
for(int
i
=
0
i
<
n
++i)
System.out.print(a[i]
+
"
")
System.out.println()
}
static
void
randomShuffle(int[]
a,
int
n)
{
for(int
i
=
0
i
<
n
++i)
{
int
r
=
(int)(Math.random()
*
a.length)
int
tmp
=
a[i]
a[i]
=
a[r]
a[r]
=
tmp
}
}
}
public void main (String[] args){int[] red=new int[7]
int blue=0
for(int i=0i<7i=i+1){
red[i]=getRandom(33)
//判断重复
while(true){
boolean needcheck=false
for(int k=0k<ik=k+1) { if(red[i]==red[k]){ needcheck=true}}
if(needcheck){red[i]=red[i]+1if(red[i]==34){red[i]=1}}else{break}
}
//判断重圆旦复结束
}
//红球赋值结搏仔束
blue=getRandom(16)
System.out.println("生成的基腔汪红球为:"+ red[0]+red[1]+red[2]+red[3]+red[4]+red[5]+red[6])
System.out.println("生成的蓝球为:"+ )
}
public int getRandom(int Max){
return Math.floor(Math.random()*33)+1
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)