VB语言实现10个数和从1,2.10这10个数字中任取6个全组合输出(每组6个不同数字)并满足条件1,2,3,6有1至2个1,2,7,8,9,10有1至3个5,6,9有1至2个和值31至33结果下面正确01-03-04-05-08-1001-03-04-05-09-1001-04-05-06
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 19:12:52
VB语言实现10个数和从1,2.10这10个数字中任取6个全组合输出(每组6个不同数字)并满足条件1,2,3,6有1至2个1,2,7,8,9,10有1至3个5,6,9有1至2个和值31至33结果下面正确01-03-04-05-08-1001-03-04-05-09-1001-04-05-06
VB语言实现10个数和
从1,2.10这10个数字中任取6个全组合输出(每组6个不同数字)
并满足条件
1,2,3,6有1至2个
1,2,7,8,9,10有1至3个
5,6,9有1至2个
和值31至33
结果下面正确
01-03-04-05-08-10
01-03-04-05-09-10
01-04-05-06-07-08
01-04-05-06-07-10
02-03-04-05-07-10
02-03-04-05-08-09
02-03-04-05-08-10
02-03-04-05-09-10
02-04-05-06-07-08
VB语言实现10个数和从1,2.10这10个数字中任取6个全组合输出(每组6个不同数字)并满足条件1,2,3,6有1至2个1,2,7,8,9,10有1至3个5,6,9有1至2个和值31至33结果下面正确01-03-04-05-08-1001-03-04-05-09-1001-04-05-06
做完了,不用任何控件,代码如下:
Dim M(6) As Byte, H(6) As Byte
Dim G(3) As Byte
Dim I As Byte, J As Byte, Hj As Integer
Const N = 10, X = 6, Y = 33
Private Sub Form_Click()
Cls
For I = 0 To X
M(I) = I: H(I) = 0
Next
Hj = 0
I = 1
Call ZuHe
Print "共有以上"; Hj; "个结果符合题目要求."
Print "单击窗口重做一遍."
Print: Print "双击窗体退出程序."
End Sub
Sub ZuHe()
Do While M(I) = 1 And M(J) = 7 And M(J) 30 And H(I) < 34) And (G(1) > 0 And G(1) < 3) And (G(2) > 0 And G(2) < 4) And (G(3) > 0 And G(3) < 3) Then
Hj = Hj + 1
Print Hj;
For J = 1 To X
If J > 1 Then Print "-";
Print M(J);
Next
Print
End If
ElseIf H(I) < Y Then
I = I + 1
M(I) = M(I - 1) + 1
Call ZuHe
I = I - 1
End If
M(I) = M(I) + 1
DoEvents
Loop
End Sub
Private Sub Form_DblClick()
End
End Sub
Private Sub Form_Load()
Form1.AutoRedraw = True
Form1.Caption = "S.T.S.-数字求和"
Form1.Width = 10000
Form1.Height = 5000
Print "本程序不用任何控件,点击窗口即可运行,结果将显示在窗口内.双击窗体退出程序."
Print: Print: Print "单击窗口继续."
End Sub
已经运行过.如果有什么问题请再留言.祝你学习进步!