输入:345,输出:
注意里面包含的空格
C=12
S=6.0
(2)输入:123,输出:
无法构成三角形
代码如下,如果有用,请点击一下采纳谢谢:
import math
x=input()
a = int(x[0])
b = int(x[1])
c = int(x[2])
if (a < b):
t=a
a=b
b=t
if (a < c):
t=a
a=c
c=t
if (b < c):
t=b
b=c
c=t
if(a>0 and b>0 and c>0):
if(a<(b+c)):
h=(a+b+c)/2
C=a+b+c
s=math.sqrt(h*(h-a)*(h-b)*(h-c))
print("C={},S={}".format(C,s))
else:
print("无法构成三角形!")
else:
print("无法构成三角形!")