首页
Java
登录
6mi
u
盘
搜
搜 索
Java
Lua 打乱数组顺序
Lua 打乱数组顺序
xiaoxiao
2021-02-28
94
function
shuffle
(
t
)
if
type(t)~=
"table"
then
return
end
local
tab
={}
local
index=
1
while
#t~=0 do
local
n=math.
random
(
0
,
#t)
if
t[n]~=nil
then
tab
[index]=t[n] table.remove(t,n) index=index+
1
end
end
return
tab
end
转载请注明原文地址: https://www.6miu.com/read-70582.html
技术
最新回复
(
0
)