从m个数字中选择nn个数字,求使用vb算出所有组合
答案:1 悬赏:0 手机版
解决时间 2021-01-17 13:34
- 提问者网友:王者佥
- 2021-01-16 12:40
从m个数字中选择nn个数字,求使用vb算出所有组合
最佳答案
- 五星知识达人网友:旧脸谱
- 2021-01-16 14:15
Option Explicit
Private n As Integer
Private k As Integer
Private a(10001) As Integer
Private Sub Command1_Click()
List1.Clear
n = Val(Text1.Text)
k = Val(Text2.Text)
Call C(1)
End Sub
Private Sub C(ByVal t As Integer)
Dim i As Integer
For i = a(t - 1) + 1 To n
a(t) = i
If t = k Then
Myprint
Else
Call C(t + 1)
End If
Next i
End Sub
Private Sub Myprint()
Dim i As Integer
Dim LinStr As String
LinStr = ""
For i = 1 To k - 1
LinStr = LinStr & a(i) & " "
Next i
LinStr = LinStr & a(k)
List1.AddItem LinStr
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯