[BOJ / Python] 5073 삼각형과 세 변

도니·2023년 4월 11일

BOJ / Python

목록 보기
67/105
post-thumbnail

문제

백준 5073 삼각형과 세 변

코드

#BOJ 5073 삼각형과 세 변

while True:
    x = list(map(int, input().split()))
    x.sort()
    if x[0] == 0 and x[1] == 0 and x[2] == 0:
        break

    if x[2] < x[0] + x[1]:
        if x[0] == x[1] and x[1] == x[2]:
            print("Equilateral")
        elif x[0]  == x[1] or x[1] == x[2] or x[2] == x[1]:
            print("Isosceles")
        else:
            print("Scalene")
    else:
        print("Invalid")

가장 긴 변과 나머지 두 변을 구하기 쉽도록 입력값을 리스트로 받고, list.sort()를 이용하여 길이 순서대로 정렬한 후 사용한다.

profile
Where there's a will, there's a way

0개의 댓글