已知三角形三个边的长度值,求三个角的大小

标签: functioncommandcstringjoin
2768人阅读 评论(0) 收藏 举报
分类:

没什么技术含量,一个余弦定理搞定:

Function angle(ByVal a As Double, ByVal b As Double, ByVal c As Double)
angle = (b * b + c * c - a * a) / (2 * b * c)
angle = Atn(-angle / Sqr(1 - angle * angle)) + 2 * Atn(1)
angle = Format(angle * 45 / Atn(1), "0.00") & "°"
End Function
Sub getangles(ByVal a As Double, ByVal b As Double, ByVal c As Double)
Dim x(6) As String
x(0) = "IF a=" & a
x(1) = "   b=" & b
x(2) = "   c=" & c
x(3) = "Then"
x(4) = "∠ABC=" & angle(b, c, a)
x(5) = "∠BAC=" & angle(a, b, c)
x(6) = "∠ACB=" & angle(c, a, b)
MsgBox Join(x, vbCrLf), vbInformation, "Result"
End Sub
Private Sub Command1_Click()
getangles 1, 2, 1.732
End Sub

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:630974次
    • 积分:8214
    • 等级:
    • 排名:第2407名
    • 原创:205篇
    • 转载:26篇
    • 译文:1篇
    • 评论:213条
    最新评论