标题:下面这段是从7个数字中取6个数字不重组合的代码,我想用递归形式把它表现出 ...
只看楼主
xiaojie_cp
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2006-6-9
 问题点数:0 回复次数:2 
下面这段是从7个数字中取6个数字不重组合的代码,我想用递归形式把它表现出来,求解
下面这段是从7个数字中取6个数字不重组合的代码,我想用递归形式把它表现出来,求解。
str = "01,02,03,04,05,06,07"
arr = Split(str,",")
length = UBound(arr)
For i = 0 To length
For j = i + 1 To length
For n = j + 1 To length
For w = n + 1 To length
For e = w + 1 To length
For r = e + 1 To length
my_String = my_String & arr(i)&" "&arr(j)&" "&arr(n)&" "&arr(w)&" "&arr(e)&" "&arr(r) & "<br>"
Next
Next
Next
Next
Next
Next
搜索更多相关主题的帖子: 递归 数字 形式 求解 代码 
2006-12-26 15:47
ehvuclz
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2005-8-12
得分:0 
帮你顶吧

我菜。我学习
2006-12-26 15:51
做人很低调
Rank: 5Rank: 5
等 级:贵宾
威 望:18
帖 子:1268
专家分:0
注 册:2006-8-2
得分:0 

<body>
<%
Dim str,arr,length,istr,iarr,le,m,ii,jj,i,j,k,l,w,e,chek
str = "01,02,03,04,05,06,07"
arr = Split(str,",")
length = UBound(arr)

istr = "i,j,k,l,w,e"
iarr = Split(istr,",")
le = Ubound(iarr)
m = 0
chek=""
For ii = 0 To le-1
For jj = m To le
If ii <> jj Then
If ii = le-1 And jj = le Then
chek = chek&"arr("&iarr(ii)&")<>arr("&iarr(jj)&")"
Else
chek = chek&"arr("&iarr(ii)&")<>arr("&iarr(jj)&") and "
End If
End If
Next
m = m+1
Next
'Response.Write(chek)
'Response.End()
For i = 0 To length
For j = 0 To length
For k = 0 To length
For l = 0 To length
For w = 0 To length
For e = 0 To length
If Eval(chek) Then
Response.Write(arr(i)&"-"&arr(j)&"-"&arr(k)&"-"&arr(l)&"-"&arr(w)&"-"&arr(e)&"<br>")
End If
Next
Next
Next
Next
Next
Next
%>
</body>


运行一下看看是不是楼主你想要的结果


其实我很低调,只是你不知道...
2006-12-26 17:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-112236-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.204663 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved