1.写一个程序段完成如下功能:
1.写一个程序段完成如下功能:
输入三角形的三条边a,b,c的值,根据其数值,判断能否构成三角形.若能,还要显示三角形的性质:等边三角形、等腰三角形、直角三角形、任意三角形
VB
Private Sub Form_Click()
Dim a(1 To 3) As Single
a(1) = InputBox("请输入三角形第一个边长","输入框")
a(2) = InputBox("请输入三角形第二个边长","输入框")
a(3) = InputBox("请输入三角形第三个边长","输入框")
For i = 2 To 3
If a(1) > a(i) Then
temp = a(1)
a(1) = a(i)
a(i) = temp
End If
Next
If a(2) > a(3) Then
temp = a(2)
a(2) = a(3)
a(3) = temp
End If
If a(1) + a(2) > a(3) And a(3) - a(1) If a(1) = a(2) And a(2) = a(3) Then
Print "该三边可以构成等边三角形"
GoTo lp
End If
If a(1) = a(2) Then
If a(1) * a(1) + a(2) * a(2) = a(3) * a(3) Then Print "该三边可以构成等腰直角三角形"
Print "该三边可以构成一般等腰三角形"
GoTo lp
End If
If a(1) * a(1) + a(2) * a(2) = a(3) * a(3) Then
Print "该三边可以构成一般直角三角形"
Else
Print "该三边可以构成一般任意三角形"
End If
End If
lp:
End Sub