作业帮 > 综合 > 作业

VB (A B C D E)排列问题

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/19 15:55:17
VB (A B C D E)排列问题
有ABCDE五个字母,他们不重复的排序结果有120种,怎么写代码才能把这120种排列求出来啊?
例如ABCDE,ABCED,ABECD.
VB (A B C D E)排列问题
'试一下:
Private Sub Command1_Click()
Dim i1, i2, i3, i4, i5, j, arr() As String, n
For i1 = 65 To 69
For i2 = 65 To 69
For i3 = 65 To 69
For i4 = 65 To 69
For i5 = 65 To 69
n = n + 1
ReDim Preserve arr(1 To n)
arr(n) = Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5)
For j = 65 To 69
If InStr(arr(n), Chr(j)) = 0 Then
n = n - 1
Exit For
End If
Next j, i5, i4, i3, i2, i1
MsgBox Join(arr)
End Su