题解 | #三角形判断#
三角形判断
http://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
while True:
try:
num = list(map(int, input().split()))
num .sort()
if num[0] + num[1] <= num[2]: # 两短边之和小于第三遍,三角形不成立
print("Not a triangle!")
elif num[0] == num[1] and num[1] != num[2]: # 两边相等但不等于第三边
print("Isosceles triangle!")
elif num[1] == num[2] and num[1] != num[0]:
print("Isosceles triangle!")
elif num[0] == num[1] == num[2]: # 三边相等
print("Equilateral triangle!")
else:
print("Ordinary triangle!")
except:
break
注意过滤顺序