我的列表L
包含可变数量的字符串{123} {/ - +} {ABCD} ...
我想构建一个递归函数来登记这些字符串字符的所有可能组合,所以上面的例子会产生:
1/A
1/B
1/B
1/D
1-A
1-B
..
3+D
答案 0 :(得分:0)
如果你有三个独立的集合,你可以使用LINQ来获取笛卡尔积,例如
from a in symbols
from b in numbers
from c in letters
select a + b + c
答案 1 :(得分:0)
Module Module1
Dim data As String() = {"123", "/-+", "abcd"}
Dim charStack As New Stack(Of Char)
Sub Main()
visitString(0)
End Sub
Sub visitString(ByVal i As Integer)
For j = 0 To data(i).Length - 1
charStack.Push(data(i)(j))
If i = data.Length - 1 Then
Dim q = String.Join("", charStack.Reverse)
Console.WriteLine(q)
Console.ReadKey()
Else
visitString(i + 1)
End If
charStack.Pop()
Next
End Sub
End Module