function xipai(mystr) xipai=”” if len(mystr)=0 then’如果是空的,那么初试化一付连续的牌 for i=1 to 52 mystr=mystr & ” ” next end if dim i,x for i=1 to 52 myarry=split(mystr) ‘myarry是下标52的数组,前0-51个有效 randomize x=cint(rnd*(ubound(myarry)-1))’前0-51个随便找一个 mystr=replace(mystr, myarry(x) & space(1),””)’从没发的牌中随便挑一张 xipai=xipai & myarry(x) & space(1) next end function function XP(n) mystr=”xipai(“”””)” dim i for i=1 to n mystr=”xipai(” & mystr & “)” next ‘XP=eval(mystr) XP=eval(mystr) end function document.write “洗牌完美版” & “” document.write “洗一次牌:” & XP(1) & “” document.write “洗两次牌:” & XP(2) & “” document.write “洗三次牌:” & XP(3) & “” document.write “洗一百次牌:” & XP(100) & “” [Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行] ‘洗牌 Dim N,S,D,P P=52’牌的数量 Set D = CreateObject(“Scripting.Dictionary”) do while D.Count<P Randomize N=Int(P * Rnd + 1) if not D.Exists(cstr(N)) then D.Add cstr(N),cstr(N) end if loop for each K in D.Keys S=S & K & " " next msgbox replace(trim(S)," ",",") [Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]