鱼C论坛

 找回密码
 立即注册
查看: 7069|回复: 60

[技术交流] Python:每日一题 150

[复制链接]
发表于 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('其他三角形。')

评分

参与人数 1荣誉 +3 鱼币 +3 收起 理由
冬雪雪冬 + 3 + 3

查看全部评分

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-9-27 11:02

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表