package 彩票中奖码生成器; import java.util.Random; public class TestRandom {
public static void main(String[] args) {
Random random=new Random();
int[] numbers=new int[6];
int index=0;
while(index<numbers.length){
int num=random.nextInt(50);
if(!isContains(numbers,num))
numbers[index++]=num;
}
java.util.Arrays.sort(numbers);
for(int i:numbers){
System.out.print(i+",");
}
}
public static boolean isContains(int[] tmp,int num){
if(num==0)
return true;
for(int i=0;i<tmp.length;i++){
if(tmp[i]==num)
return true;
}
return false;
}
}