VB语言从8选6全组合有条件从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每组中1,2,3,6中最少有1至2个,高手来啊要有源代码下面输出结果就正确01-02-08
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 03:37:08
VB语言从8选6全组合有条件从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每组中1,2,3,6中最少有1至2个,高手来啊要有源代码下面输出结果就正确01-02-08
VB语言从8选6全组合有条件
从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)
并且满足条件每组中1,2,3,6中最少有1至2个,
高手来啊要有源代码
下面输出结果就正确
01-02-08-09-12-16
01-03-08-09-12-16
01-06-08-09-12-16
02-03-08-09-12-16
02-06-08-09-12-16
03-06-08-09-12-16
VB语言从8选6全组合有条件从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每组中1,2,3,6中最少有1至2个,高手来啊要有源代码下面输出结果就正确01-02-08
Private Sub Form_Load()
s = "1,2,3,6,8,9,12,16"
s1 = Split(s, ",")
For i = 1 To 3
s3 = s1(i - 1)
For i2 = i + 1 To 4
s4 = s3 & "-" & s1(i2 - 1)
For i3 = i2 + 1 To 5
s5 = s4 & "-" & s1(i3 - 1)
For i4 = i3 + 1 To 6
s6 = s5 & "-" & s1(i4 - 1)
For i5 = i4 + 1 To 7
s7 = s6 & "-" & s1(i5 - 1)
For i6 = i5 + 1 To 8
s8 = s7 & "-" & s1(i6 - 1)
i7 = 0
If InStr(s8, "1") = 1 Then
i7 = i7 + 1
End If
If InStr(s8, "-2-") > 0 Or InStr(s8, "2") = 1 Then
i7 = i7 + 1
End If
If InStr(s8, "-3-") > 0 Or InStr(s8, "3") = 1 Then
i7 = i7 + 1
End If
If InStr(s8, "-6-") > 0 Then
i7 = i7 + 1
End If
If i7 = 1 Or i7 = 2 Then
s2 = s2 & vbCrLf & s8
End If
Next
Next
Next
Next
Next
Next
Clipboard.Clear
Clipboard.SetText s2
End Sub