用vb编写程序,输出30以内的勾股数组合,要输出到窗体的文本框中 并且要求使用子程序来实现

如题所述

Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Text1.Text = ""
For i = 1 To 30
   For j = i + 1 To 30
       For k = j + 1 To 30
         If ggs(i, j, k) = True Then
           Text1.Text = Text1.Text & i & "," & j & "," & k & vbCrLf
         End If
        Next k
    Next j
Next i
End Sub

Public Function ggs(a As Integer, b As Integer, c As Integer) As Boolean
If a * a + b * b = c * c Then ggs = True
End Function

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-05-26
Option Explicit

Private Function fun(n As Integer) As String
    Dim i As Integer, j As Integer, k As Integer
    
    For i = 3 To n
        For j = i To n
            For k = j To n
                If i * i + j * j = k * k Then
                    fun = fun & i & "," & j & "," & k & vbCrLf
                End If
                DoEvents
            Next k
        Next j
    Next i
End Function

Private Sub Command1_Click()
    
    Me.Caption = "Made by xkwy."
    
    Text1.Text = fun(30)
    
End Sub


第2个回答  2015-05-27
病情分析:
你好:没事的黄体酮是保胎的,就是医生所说的那样,你不用怕,这个不会有问题的。
指导意见:
每一天打两针,就早晚各一次就可以了。如果你感觉不好的话你到医院看看。