VB (A B C D E)排列问题有ABCDE五个字母,他们不重复的排序结果有120种,怎么写代码才能把这120种排列求出来啊?例如ABCDE,ABCED,ABECD.
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/27 23:13:07
![VB (A B C D E)排列问题有ABCDE五个字母,他们不重复的排序结果有120种,怎么写代码才能把这120种排列求出来啊?例如ABCDE,ABCED,ABECD.](/uploads/image/z/8836590-30-0.jpg?t=VB+%EF%BC%88A+B+C+D+E%EF%BC%89%E6%8E%92%E5%88%97%E9%97%AE%E9%A2%98%E6%9C%89ABCDE%E4%BA%94%E4%B8%AA%E5%AD%97%E6%AF%8D%2C%E4%BB%96%E4%BB%AC%E4%B8%8D%E9%87%8D%E5%A4%8D%E7%9A%84%E6%8E%92%E5%BA%8F%E7%BB%93%E6%9E%9C%E6%9C%89120%E7%A7%8D%2C%E6%80%8E%E4%B9%88%E5%86%99%E4%BB%A3%E7%A0%81%E6%89%8D%E8%83%BD%E6%8A%8A%E8%BF%99120%E7%A7%8D%E6%8E%92%E5%88%97%E6%B1%82%E5%87%BA%E6%9D%A5%E5%95%8A%3F%E4%BE%8B%E5%A6%82ABCDE%2CABCED%2CABECD.)
VB (A B C D E)排列问题有ABCDE五个字母,他们不重复的排序结果有120种,怎么写代码才能把这120种排列求出来啊?例如ABCDE,ABCED,ABECD.
VB (A B C D E)排列问题
有ABCDE五个字母,他们不重复的排序结果有120种,怎么写代码才能把这120种排列求出来啊?
例如ABCDE,ABCED,ABECD.
VB (A B C D E)排列问题有ABCDE五个字母,他们不重复的排序结果有120种,怎么写代码才能把这120种排列求出来啊?例如ABCDE,ABCED,ABECD.
'试一下:
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 Sub