Py||Judge triangle

谁说胖子不能爱 提交于 2019-12-02 11:02:00

题目描述
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")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!