VB程序题 从键盘输入三条边A,B,C,如果能构成三角形,则计算他的面积

 我来答
zhyulily
2011-04-21 · TA获得超过260个赞
知道小有建树答主
回答量:217
采纳率:0%
帮助的人:83.3万
展开全部
Private Function GetArea(intA As Integer, intB As Integer, intC As Integer) As Boolean
Dim intTmp As Integer
intTmp = -1 '若不是三角形,则返回-1,也可以返回其它数。
If IsBiger(intA+intB,intC) And _
IsBiger(intA+intC,intB) And _
IsBiger(intB+intC,intA) And _
IsSmaller(intA-intB,intC) And _
IsSmaller(intA-intC,intB) And _
IsSmaller(intB-intC,intA) And _
IsSmaller(intB-intA,intC) And _
IsSmaller(intC-intA,intB) And _
IsSmaller(intC-intB,intA) Then
'使用“三斜求模肢积” 计算面纯握积
intTmp = Sqr(1/4 * (intC^2 * intA^2 - ((intC^2 + intA^2 - intB^2)/2)^2))
End If

GetArea = intTmp
End Function

Private Function IsBiger(intA As Integer, intB As Integer) As Boolean
Dim isTmp As Boolean
isTmp = False
if intA > intB then isTmp = True
IsBiger = isTmp
End Function

Private Function IsSmaller(intA As Integer, intB As Integer) As Boolean
Dim isTmp As Boolean
isTmp = False
if intA <旦裤世 intB then isTmp = True
IsSmaller = isTmp
End Function
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式