JS代码如下:
/**
* @arrange (512.笔记) jb51.cc
* 随机生成n个1-maxNum之间的值不会重复的整数组,十位补0
* @param maxNum 1-几
* @param n 多少个
* @returns {arr}
*/
var randomIntNum = function(maxNum,n) {
var oArr = [];
var newArr = [];
var rNum;
for (var i = 0; i < n;) {
rNum = parseInt(Math.random() * maxNum + 1);
if (!oArr[rNum]) {
oArr[rNum] = rNum;
(rNum < 10) && (rNum = '0' + rNum);
newArr.push(rNum);
i++;
}
}
return newArr;
}