|
发表于 2018-2-7 14:28:40
|
显示全部楼层
print('----------判定三角形----------')
temp1=input('a:')
temp2=input('b:')
temp3=input('c:')
while not (temp1.isdigit() and temp2.isdigit() and temp3.isdigit()):
temp1=input('输入了错误的数据类型,请重新输入a:')
temp2=input('输入了错误的数据类型,请重新输入b:')
temp3=input('输入了错误的数据类型,请重新输入c:')
a=int(temp1)
b=int(temp2)
c=int(temp3)
if not ((a+b)>c and (a+c)>b and (b+c)>a and abs(a-b)<c and abs(b-c)<a and abs(a-c)<b):
print('边长a,b,c无法构成三角形。')
elif (a==b and b==c):
print('等边三角形。')
elif ((a**2+b**2==c**2)or(b**2+c**2==a**2)or(a**2+c**2==b**2))and(a==b or b==c or a==c ):
print('等边直角三角形。')
elif (a**2+b**2==c**2)or(b**2+c**2==a**2)or(a**2+c**2==b**2):
print('直角三角形。')
elif a==b or b==c or a==c:
print('等腰三角形。')
else:
print('其他三角形。')
|
评分
-
查看全部评分
|