Posted on 2006-10-17 15:02
laifangsong 阅读(284)
评论(0) 编辑 收藏 所属分类:
算法

<%

'递归实现无重复组合

Dim aNum
aNum = Array("1","2","3","4")

Call Combination(0, aNum, "")


Function Combination(n_Cur, a_Num, s)
Dim i, bound
bound = UBound(a_Num)
If n_Cur > bound Then
Response.Write s & "<br />"
Exit Function
End If
For i = 0 To bound
If IsExists(s, a_Num(i)) = False Then
Call Combination(n_Cur+1, a_Num, s & a_Num(i))
End If
Next
End Function


Function IsExists(s_Parent, s_Sub)
If InStr(s_Parent, s_Sub) > 0 Then
IsExists = True
Else
IsExists = False
End If
End Function

%>
