VB语言从8选6全组合过滤行从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每行中有5个相同数字就过滤,只保留一行例如结果1-2-3-6-8-91-2-3-6-8-121-2-3-6-8-1
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 19:04:13
VB语言从8选6全组合过滤行从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每行中有5个相同数字就过滤,只保留一行例如结果1-2-3-6-8-91-2-3-6-8-121-2-3-6-8-1
VB语言从8选6全组合过滤行
从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)
并且满足条件每行中有5个相同数字就过滤,只保留一行
例如结果
1-2-3-6-8-9
1-2-3-6-8-12
1-2-3-6-8-16
只需保留任意一行
1-2-3-6-8-9
高手来啊要有源代码
VB语言从8选6全组合过滤行从1,2,3,6,8,9,12,16这8个数字中任取6个全组合输出(每组有不同的6个数字组成)并且满足条件每行中有5个相同数字就过滤,只保留一行例如结果1-2-3-6-8-91-2-3-6-8-121-2-3-6-8-1
Sub DoArr()
Dim a(9) As Integer
a(1) = 1:a(2) = 2:a(3) = 3
a(4) = 6:a(5) = 8:a(6) = 9
a(7) = 12:a(8) = 16
Dim Arr As String
Dim newArr As String,Oldarr As String
Open "d:\456.txt" For Output As #12
For i = 1 To 8
For j = i + 1 To 8
Arr = ""
For m = j + 1 To 8
For n = m + 1 To 8
For p = n + 1 To 8
For q = p + 1 To 8
newArr = a(i) & "-" & a(j) & "-" & a(m) & "-" & a(n) & "-" & a(p) '前5位
If Oldarr = newArr Then
Arr = "" '有重复为"";换行
Else
Arr = newArr & "-" & a(q)
Oldarr = newArr '不重复,更改old值
End If
Print Arr
Print #12,Arr
Next q
Next p
Next n
Next m
Next j
Next i
Close #12
End Sub
Private Sub Command1_Click()
Cls
DoArr
End Sub
456.txt
1-2-3-6-8-9
1-2-3-6-9-12
1-2-3-6-12-16
1-2-3-8-9-12
1-2-3-8-12-16
1-2-3-9-12-16
1-2-6-8-9-12
1-2-6-8-12-16
1-2-6-9-12-16
1-2-8-9-12-16
1-3-6-8-9-12
1-3-6-8-12-16
1-3-6-9-12-16
1-3-8-9-12-16
1-6-8-9-12-16
2-3-6-8-9-12
2-3-6-8-12-16
2-3-6-9-12-16
2-3-8-9-12-16
2-6-8-9-12-16
3-6-8-9-12-16