laifangsong's blog

取长补短,精益求精。 (打个广告,想做手机网站和asp/asp.net网站的可以跟我联系.QQ:25313644)
posts - 51, comments - 193, trackbacks - 0, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

递归实现无重复组合

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

%
>

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2006-10-17 15:46 编辑过


相关链接: