public int[] randomIntList(int length,int max) throws Exception{
if(length > max){
throw new Exception("length必须小于等于max");
}
int[] r = new int[length];
ArrayList<Integer> t = new ArrayList<Integer>();
for(int i = 0 ; i < max ; i ++){
t.add(i);
}
int i = 0 ;
while(i < length){
int tr = new Random().nextInt(t.size());
r[i] = t.get(tr);
t.remove(tr);
i++;
}
return r;
}
if(length > max){
throw new Exception("length必须小于等于max");
}
int[] r = new int[length];
ArrayList<Integer> t = new ArrayList<Integer>();
for(int i = 0 ; i < max ; i ++){
t.add(i);
}
int i = 0 ;
while(i < length){
int tr = new Random().nextInt(t.size());
r[i] = t.get(tr);
t.remove(tr);
i++;
}
return r;
}