标题: 下面这段是从7个数字中取6个数字不重组合的代码,我想用递归形式把它表现出 ... [打印本页] 作者: Yaci 时间: 2010-1-16 03:46 标题: 下面这段是从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作者: 让爱留在心底 时间: 2010-1-16 03:46
帮你顶吧作者: cs牛人 时间: 2010-1-16 03:46
<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>