问个跟‘全排列’有关的简单问题
比如有3个字符:1, 2, 3
它的全排列就有:123, 132, 213, 231, 312, 321
有如下代码能将这6个结果输出:
Private Sub Command1_Click()
Const TEXT As String = "1231213213231"
Dim i As Long
For i = 1 To 11 Step 2
Debug.Print Mid$(TEXT, i, 3)
Next
End Sub
Private Sub Command1_Click()
Const TEXT As String = "12312"
Dim i As Long
Dim s As Long
Dim s1 As Long
For i = 1 To 3
s = Mid$(TEXT, i, 3)
s1 = StrReverse(s)
Debug.Print s, s1
Next
End Sub
Private Sub Command1_Click()
Const TEXT As String = "123"
Dim i As Long
Dim s As Long
Dim s1 As Long
For i = 1 To 3
s = Mid(TEXT, i, 3) & Left(TEXT, i - 1)
s1 = StrReverse(s)
Debug.Print s, s1
Next i
End Sub