题目
一个三角形的三边长分别是a、b、c,那么它的面积为 ,其中p= 。输入这三个数字,计算三角形的面积,四舍五入精确到1位小数。保证能构成三角形,0≤a,b,c≤1000,每个边长输入时不超过2位小数。
答案:解: import math a,b,c=map(float,input().split()) #连续输入三个浮点数 p=0.5*(a+b+c) s=p*(p-a)*(p-b)*(p-c) s=math.sqrt(s) s=int(s*100) m=s%10 if m>=5: s=s+10 else s=(s-m)/100 print(s)