[发布]组合的算法(vbs)
一个数组所有元素的可能组合
用的是摘果子的算法。
<%
dim result
stra=split("1,2,3,4,5",",")
call combo(stra)
sub combo(str)
for i=0 to ubound(str)
ftmp=pick(str,i)
combo(ftmp)
next
end sub
function pick(strarray,k)
for i=0 to ubound(strarray)
if i<>k then temp=temp&strarray(i)&","
next
if len(temp)>1 then
temp=left(temp,len(temp)-1)
end if
ww temp
pick=split(temp,",")
end function
sub ww(t)
response.write t
response.write "<BR>"
response.flush
end sub
%>