判断三条边能否构成三角形 python

时间:2025-03-15 17:55:54
def triangle(a,b,c): if a <= 0 or b <= 0 or c <= 0: print('三角形的三边必须是大于0的数,不符规则!') elif a + b <= c or b + c <= a or c + a <= b: print('两边之和大于第三边,不符规则!') else: print('输入的三条边符合组成三角形的编程规则!') a=float(input('请输入边长 a:')) b=float(input('请输入边长 b:')) c=float(input('请输入边·长 c:')) triangle(a,b,c)