VB语言实现10个数和从1,2.10这10个数字中任取6个全组合输出(每组6个不同数字)并满足条件1,2,3,6有1至2

1个回答

  • 做完了,不用任何控件,代码如下:

    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

    已经运行过.如果有什么问题请再留言.祝你学习进步!