visual basic 程序设计教程

来源:百度知道 编辑:UC知道 时间:2024/05/08 07:56:29
1.编写Command1的Click事件,在窗体上显示(a,b,c)组,其中(a,b,c)为三个整数,它们能构成直角三角形的三条边,且1≤a≤b≤c≤50(即不出现重复三角形),并在统计这样的三角形个数。(注:直角三角形的三条边要符合勾股定理)
1≤a≤b≤c≤50可以写成如下:
For a=1 to 50
For b=a to 50
For c=b to 50

Private Sub Command1_Click()
Dim a, b, c, n As Integer
n = 0
For a = 1 To 50
For b = a To 50
For c = b To 50
If a + b > c And c - b < a Then
n = n + 1
Print a, b, c
End If
Next c
Next b
Next a
Print n
End Sub
答案太多了 用print不能完全显示 自己改成text显示吧