题解 | 计算三角形的周长和面积
计算三角形的周长和面积
https://www.nowcoder.com/practice/109a44d649a142d483314e8a57e2c710
from math import sqrt
lines = input()
a, b, c = map(int, lines.split())
def compute(a, b, c):
circumferences = a + b + c
# 海伦公式
s = circumferences / 2
areas = sqrt(s * (s - a) * (s - b) * (s - c))
return circumferences, areas
circumference, area = compute(a, b, c)
print(f"{circumference=:.2f} {area=:.2f}")
查看8道真题和解析