<SCRIPT LANGUAGE=vbscript >
'洗牌最新版
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)," ",",")
</SCRIPT>
<SCRIPT LANGUAGE=vbscript >
Dim N,S,D
Set D = CreateObject("Scripting.Dictionary")
do while D.Count<9
Randomize
N=Int(9 * 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)," ",",")
</SCRIPT>
洗牌完美版:
<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>
<script language=vbs>
'功能:从很多字串中排除相同字串
'输入:很多字串组成的数组:
dim A,B
A=array("字串1","字串2","字串3","字串1","字串2","字串1","字串4")
'输出:
B=F(A)
'显示结果:B=array("字串1","字串2","字串3","字串4")
for each bbb in B
document.write bbb & "<br/>"
next
'函数部分
function F(x)'这里x是形参
dim S,D
Set D = CreateObject("Scripting.Dictionary")
for each xxx in x
if not d.Exists(xxx) then D.Add xxx,xxx
next
for each key in D.Keys
S=S & key & " "
next
set D=nothing
F=split(trim(S))
end function
</script>
<tr><td>please enter:</td></tr><input type=text name=text1>
<%
dim strf
dim n
dim i
dim lenf
dim flag
n=0
strf=request("text1")
'决断“,”是不是符合要求
strf=split(strf,",")
for i=lbound(strf) to ubound(strf)
if isnumber '看是不是数字,不用我说吧? then ****
n=n+2
lenf=len(strf(i))
if lenf=n then
if ****
****用MID函数看是不是两两相等,不用我说了吧?
end if
flag=true
else
flag=false
end if
if n>=ubound(strf) then exit do
next
if flag=true then response.write"right"'判断为正确的输入
if flag=false then response.write"false"