VB语言从11选6全组合相连从1,2,3.11这11个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每组有2个相连号(比如1-2,2-3等叫做相连号)高手来啊要有源代码下面输出结果就正确
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 01:02:59
VB语言从11选6全组合相连从1,2,3.11这11个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每组有2个相连号(比如1-2,2-3等叫做相连号)高手来啊要有源代码下面输出结果就正确
VB语言从11选6全组合相连
从1,2,3.11这11个数字中任取6个全组合输出(每组有不同的6个数字组成)
并且满足条件每组有2个相连号(比如1-2,2-3等叫做相连号)
高手来啊要有源代码
下面输出结果就正确
01-02-04-06-08-10
01-02-04-06-08-11
01-02-04-06-09-11
01-02-04-07-09-11
01-02-05-07-09-11
01-03-04-06-08-10
01-03-04-06-08-11
01-03-04-06-09-11
01-03-04-07-09-11
01-03-05-06-08-10
01-03-05-06-08-11
01-03-05-06-09-11
01-03-05-07-08-10
01-03-05-07-08-11
01-03-05-07-09-10
01-03-05-07-10-11
01-03-05-08-09-11
01-03-05-08-10-11
01-03-06-07-09-11
01-03-06-08-09-11
01-03-06-08-10-11
01-04-05-07-09-11
01-04-06-07-09-11
01-04-06-08-09-11
01-04-06-08-10-11
02-03-05-07-09-11
02-04-05-07-09-11
02-04-06-07-09-11
02-04-06-08-09-11
02-04-06-08-10-11
每组有2个相连号,难道还不清楚明白还要在文字上钻
VB语言从11选6全组合相连从1,2,3.11这11个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每组有2个相连号(比如1-2,2-3等叫做相连号)高手来啊要有源代码下面输出结果就正确
01-02-04-06-08-10里有2个相连号?
按我的理解写的代码
Dim s(0 To 6) As String
Private Sub Form_Load()
s1 = Split("1,2,3,4,5,6,7,8,9,10,11", ",")
add s, s1, 1, 6, 1
End Sub
Sub add(s, s1, n1, n2, n3)
For i = n1 To n2
s(n3) = s1(i - 1)
If n3 < 6 Then
add s, s1, i + 1, n2 + 1, n3 + 1
Else
s2 = s(1)
For i2 = 2 To 6
s2 = s2 & "-" & s(i2)
Next
lianhao = 0
For i3 = 1 To 10
If InStr(s2, i3 & "-" & i3 + 1) > 0 Then
lianhao = lianhao + 1
End If
Next
If lianhao = 2 Then
s3 = s3 & s2 & vbCrLf
End If
End If
Next
Text1.Text = Text1.Text & s3
End Sub