var fun2 = function(n, k) {
var returnArr = []
returnArr[0] = Math.ceil(Math.random() * n)
var template = 0
for (let i = 1; i < k; i ++) {
template = Math.ceil(Math.random() * n)
for(let j = 0; j < returnArr.length; j ++) {
if(template === returnArr[j]) {
i --
break
}
else { returnArr.push(template) }
}
}
return returnArr
}
fun2(10,5)
为撒呢?
GCT1015
蓝山帝景
相关分类