题目描述
Write a program to determine if the given three edges can form a triangle.
The types of triangles include: equilateral triangles, isosceles triangles, right triangles, regular triangles
It is also possible that a triangle cannot be formed.
输入
The input consists of multiple lines of data, each line consisting of three positive integers, a, b, c representing the length of the three sides of the triangle.
输出
For each line of input, do the following processing and wrap:
1.If the triangle is an equilateral triangle, output DB.
2.If it is not an equilateral triangle, it is an isosceles triangle, output DY
3.If it is not an isosceles triangle, it is a right triangle, output ZJ
4.If it is not equal, it is not isosceles, nor is it right angle, output PT
5.If the length of the three sides cannot form a triangle, output ERROR
样例输入 Copy
3 4 5
2 2 3
样例输出 Copy
ZJ
DY
import sys
while True:
a,b,c=map(int,input().split())
if(a+b>c and a+c>b and b+c>a):
if a==b and b==c:
print("DB")
else:
if a==b or b==c:
print('DY')
else:
if b*b+c*c==a*a or a*a+c*c==b*b or a*a+b*b==c*c:
print('ZJ')
else:
print("PT")
else:
print("ERROR")
来源:https://blog.csdn.net/Lhw_666/article/details/102754585