某程序规定:"输入三个正数 a 、 b 、 c 分别作为三边的边长构成三角形。通过程序判定所构成的三角形的类型,当此三角形为一般三角形、等腰三角形及等边三角形时,分别作计算 … "。
- def isTriabgle():
- try:
- a= int(input("请输入第一边边长:"))
- b = int(input("请输入第一边边长:"))
- c = int(input("请输入第一边边长:"))
- if(a>0 and b>0 and c>0):
- if(a==b==c):
- print("等边三角形")
- elif((a+b>c and abs(a-b)<c) or (a+c>b and abs(a-c)<b) or (b+c>a and abs(b-c)<a)):
- if(a==b or a==c or b==c):
- print("等腰三角形")
- else:
- print("一般三角形")
- else:
- print("不是三角形0")
- except:
- print("输入有误")
- if __name__=='__main__':
- isTriabgle()
[color=rgb(15, 199, 122) !important]复制代码
|