linux下的python小程序——三角形面積

#!/usr/bin/python
##file of sanjiaoxing mianji

import math
a = int(raw_input('please enter side a:'))
b = int(raw_input('please enter side b:'))
c = int(raw_input('please enter side c:'))
if a + b <= c or b + c <= a or a + c <= b:
        out = str(a)+','+str(b)+','+str(c)+" can't make a triangle"
else:
        p = (a + b + c )/2.0
        s =math.sqrt(p * (p - a) * (p - b) * (p - c))
        out = "the area of this trangle is%.2f " % s
print out
 

使用海倫公式,給初學者參考,我也是初學者......

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章