VB 代码 输出三角形的面积
Private Sub Command1_Click()
Dim a As Double
Dim b As Double
Dim c As Double
Dim p As Double
Dim s As Double
a = InputBox("输入一个数")
b = InputBox("输入一个数")
c = InputBox("输入一个数")
If a + b > c And a + c > b And b + c > a Then
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
MsgBox s
Else
MsgBox ("不能构成三角形")
End If
End Sub
Dim a As Double
Dim b As Double
Dim c As Double
Dim p As Double
Dim s As Double
a = InputBox("输入一个数")
b = InputBox("输入一个数")
c = InputBox("输入一个数")
If a + b > c And a + c > b And b + c > a Then
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
MsgBox s
Else
MsgBox ("不能构成三角形")
End If
End Sub