设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 58|回复: 3
打印 上一主题 下一主题

下面这段是从7个数字中取6个数字不重组合的代码,我想用递归形式把它表现出 ...

[复制链接]
跳转到指定楼层
1#
发表于 2010-1-16 03:46:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
下面这段是从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
2#
发表于 2010-1-16 03:46:47 | 只看该作者
帮你顶吧
回复 支持 反对

使用道具 举报

3#
发表于 2010-1-16 03:46:51 | 只看该作者
<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>


运行一下看看是不是楼主你想要的结果
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-18 20:03 , Processed in 0.117057 second(s), 9 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表