python中用海倫公式計算三角形面積


 

 


#計算三角形的面積

#第一步先輸入三個邊長的值
# a = float(input("輸入三角形第一邊長:"))
# b = float(input("輸入三角形第二邊長:"))
# c = float(input("輸入三角形第三邊長:"))
#第二步判斷是否構成三角形
# while a + b < c or b + c < a or b + c < a:
# print("輸入的邊不構成三角形,請重新輸入")
# a = float(input("輸入三角形第一邊長:"))
# b = float(input("輸入三角形第二邊長:"))
# c = float(input("輸入三角形第三邊長:"))
# #第三步計算三角形的面積
# c1 = (a + b + c)/2
# s=(c1*(c1-a)*(c1-b)*(c1-c))**0.5
# print("三角形的面積為:%0.2f"%s)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM