洗牌完美版:
<SCRIPT LANGUAGE=vbscript >
function xipai(mystr)
xipai=""
if len(mystr)=0 then'如果是空的,那么初试化一付连续的牌
for i=1 to 52
mystr=mystr & "<" & i & "> "
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)
end function
document.write "洗牌完美版" & "<br/>"
document.write "洗一次牌:" & XP(1) & "<br/>"
document.write "洗两次牌:" & XP(2) & "<br/>"
document.write "洗三次牌:" & XP(3) & "<br/>"
document.write "洗一百次牌:" & XP(100) & "<br/>"
</SCRIPT>