洗牌算法
2021-02-14 19:20
阅读:490
标签:dex cti while min ref splice ice shuff random 参考:https://juejin.im/post/5cef46226fb9a07eaf2b7516 洗牌算法 标签:dex cti while min ref splice ice shuff random 原文地址:https://www.cnblogs.com/dadouF4/p/12720078.html
function shuffle(arr){
var newArr = [];
while (arr.length){
var randomIndex = Math.floor(Math.random() * arr.length);
newArr.push(arr.splice(randomIndex,1)[0]);
}
return newArr;
}
评论
亲,登录后才可以留言!