以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请教袍大师  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=77837)

--  作者:hbhb
--  发布时间:2015/11/26 11:03:00
--  请教袍大师
大师:请问如何用代码求a、b、c、d、e、f的组合?
--  作者:大红袍
--  发布时间:2015/11/26 11:32:00
--  

mark 组合排列

 

内部函数 loop

 

Dim a() As String = args(0)
Dim n As Integer = args(1)
Dim m As Integer = args(2)
Dim b() As String = args(3)
Dim Mm As Integer = args(4)

For i As Integer = n To m Step -1
    b(m-1) = i-1
    If m > 1 Then
        Functions.Execute("loop", a, i-1, m-1, b, Mm)
    Else
        Dim result As String = ""
        For j As Integer = Mm - 1 To 0 Step -1
            result &= a(b(j)) & "|"
        Next
        output.show(result.Trim("|"))
    End If
Next

 

调用

 

Dim a() As String = {"a", "b", "c", "d"}
Dim b(a.length-1) As String

\'n -> 元素个数
\'m -> 选取多少个元素
\'Mn -> 层级
For i As Integer = 1 To 4
Functions.Execute("loop", a, a.length, i, b, i)
Next


--  作者:hbhb
--  发布时间:2015/11/26 11:42:00
--  
谢谢!