所有组合我有这样的代码:获取无重复
Dim combinations As New List(Of String)
Dim word As String = "abc"
For c1 = 0 To word.Length - 1
combinations.Add(word(c1))
For c2 = 0 To word.Length - 1
If c2 <> c1 Then
combinations.Add(word(c1) & word(c2))
For c3 = 0 To word.Length - 1
If c3 <> c2 And c3 <> c1 Then
combinations.Add(word(c1) & word(c2) & word(c3))
End If
Next
End If
Next
Next
输出:
a, ab, abc, ac, acb, b, ba, bac, bc, bca, c, ca, cab, cb, cba
如何使一个函数,它会做同样的事情无限字长?
问题:家庭作业?建议:谷歌“vb.net permutation”:) – paulsm4 2012-01-02 23:51:24
有一个非常有效的方法来做出所有组合的时候,有一个限制(足够高,可以肯定)的字母数,例如32或64. – dasblinkenlight 2012-01-02 23:55:17
@ paulsm4我不知道这个combinatorics类型是如何被调用的。这不是通常的排列或组合类型。 – Cobold 2012-01-02 23:57:56