VB:编程计算三角形面积
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim
a!,
b!,
c!,
s!,
p!
a
=
InputBox("请输入第一条边长")
b
=
InputBox("请输入第二条边长")
c
=
InputBox("请输入第三条边长")
If
a
+
b
<=
c
Or
b
+
c
<=
a
Or
c
+
a
<=
b
Then
Print
"这样的三角形不存在"
Else
p
=
(a
+
b
+
c)
/
2
s
=
Sqr(p
*
(p
-
a)
*
(p
-
b)
*
(p
-
c))
Print
"这个三角形的面积是";
s
End
If
a!,
b!,
c!,
s!,
p!
a
=
InputBox("请输入第一条边长")
b
=
InputBox("请输入第二条边长")
c
=
InputBox("请输入第三条边长")
If
a
+
b
<=
c
Or
b
+
c
<=
a
Or
c
+
a
<=
b
Then
"这样的三角形不存在"
Else
p
=
(a
+
b
+
c)
/
2
s
=
Sqr(p
*
(p
-
a)
*
(p
-
b)
*
(p
-
c))
"这个三角形的面积是";
s
End
If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询