Как я могу записать все возможные комбинации на консоль? Например, если пользователь вводит abc, он будет писать aaa, aab, aac, abb, abc, acc, bbb, bbc, ccc. Пожалуйста, помогите мне.
Вот код:
Dim abc() As String = {"a", "b", "c"} '
Sub Main()
Console.WriteLine("Enter the amount of characters")
Dim count As Integer = Console.ReadLine
outputStrings("", count)
Console.ReadLine()
End Sub
Private Sub outputStrings(ByVal startString As String, ByVal letterCount As Integer)
For i = 0 To abc.Length - 1
Dim temp As String = startString
temp += abc(i)
If temp.Length = letterCount Then
Console.WriteLine(temp)
If i = abc.Length - 1 Then
Console.WriteLine("----")
End If
Else
outputStrings(temp, letterCount)
End If
Next
End Sub
Что-то должно быть сделано после пунктирных линий, чтобы удалить нежелательную перестановку, чтобы исключить только допустимые комбинации.