模拟摇奖:从1-36中随机抽出8个不重复的数字(math)

public class Yaojiang {

public static void main(String[] args) {
	// TODO 自动生成的方法存根

int[] a=new int[8];
for(int i=0;i<8;i++)
{
a[i]=(int)Math.ceil(Math.random()*36);
for(int j=0;j<i;j++)
{
if(a[i]==a[j])
{
i--;break;
}
}
}
for(int e:a)
{
System.out.print(e+" ");
}
}

}

posted @ 2016-09-13 20:52  削肾客  阅读(246)  评论(0编辑  收藏  举报