/**
* 生成n个small-big的不重复随机数字
*
* @param n
* 随机数字个数
* @param n
* 随机数字个数
* @return 随机数字数组
*/
public static int[] generateDifNums(int n, int small, int big) {
int length = big - small + 1;
int[] seed = new int[length];
for (int i = 0; i < length; i++) {
seed[i] = small + i;
}
int[] ranArr = new int[n];
Random ran = new Random();
for (int i = 0; i < n; i++) {
int j = ran.nextInt(length - i);
ranArr[i] = seed[j];
seed[j] = seed[length - 1 - i];
}
return ranArr;
}
学java的可以加入我的团队“java大牛”
追问java大牛是什么团队?
追答http://zhidao.baidu.com/team/search?kw=java%B4%F3%C5%A3
只是我建的一个互助学习java的百度知道团队,随便宣传下的呵呵