vb怎么做排列组合
A组包含1To16,B组包含2To18,C组包含5To23,D组包含8To28,E组包含13To32,F组包含21To33,求排列组合S(A,B,C,D,E,F)有多少组...
A组包含1 To 16,B组包含2 To 18,C组包含5 To 23,D组包含8 To 28,E组包含13 To 32,F组包含21 To 33,求排列组合S(A,B,C,D,E,F)有多少组并列出,组合S中要求A<B<C<D<E<F,求哪位高手帮忙,谢谢!
展开
1个回答
展开全部
这个你用循环嵌套就可以完成:
窗体上添加一个列表框和一个按钮,代码如下:
Option Explicit
Private Sub Command1_Click()
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer
For A = 1 To 16
For B = 2 To 18
For C = 5 To 23
For D = 8 To 28
For E = 13 To 32
If A < B And B < C And C < D And D < E Then
List1.AddItem A & "," & B & "," & C & "," & D & "," & E
End If
Next E
Next D
Next C
Next B
Next A
End Sub
我的计算机比较旧了,大约需要25秒钟
窗体上添加一个列表框和一个按钮,代码如下:
Option Explicit
Private Sub Command1_Click()
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer
For A = 1 To 16
For B = 2 To 18
For C = 5 To 23
For D = 8 To 28
For E = 13 To 32
If A < B And B < C And C < D And D < E Then
List1.AddItem A & "," & B & "," & C & "," & D & "," & E
End If
Next E
Next D
Next C
Next B
Next A
End Sub
我的计算机比较旧了,大约需要25秒钟
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询