vb三角形面积编程代码
1个回答
展开全部
Private Sub Form_Load()
Do
Dim a As Single, b As Single, c As Single, p As Single, s As Single
a = Val(InputBox("请输入三角形第1条边长"))
b = Val(InputBox("请输入三角形第2条边长"))
c = Val(InputBox("请输入三角形第3条边长"))
s = (a + b + c) / 2
If a >= s Or b >= s Or c >= s Then
MsgBox "不能构成三角形"
Else
area = Sqr(s * (s - a) * (s - b) * (s - c))
MsgBox "面积为" & area
End If
Loop
End
End Sub
Do
Dim a As Single, b As Single, c As Single, p As Single, s As Single
a = Val(InputBox("请输入三角形第1条边长"))
b = Val(InputBox("请输入三角形第2条边长"))
c = Val(InputBox("请输入三角形第3条边长"))
s = (a + b + c) / 2
If a >= s Or b >= s Or c >= s Then
MsgBox "不能构成三角形"
Else
area = Sqr(s * (s - a) * (s - b) * (s - c))
MsgBox "面积为" & area
End If
Loop
End
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询