Python/백준
[백준] 10101 삼각형 외우기 Python
황진수
2024. 6. 22. 00:45
https://www.acmicpc.net/problem/10101
📝 문제
창영이는 삼각형의 종류를 잘 구분하지 못한다. 따라서 프로그램을 이용해 이를 외우려고 한다.
삼각형의 세 각을 입력받은 다음,
- 세 각의 크기가 모두 60이면, Equilateral
- 세 각의 합이 180이고, 두 각이 같은 경우에는 Isosceles
- 세 각의 합이 180이고, 같은 각이 없는 경우에는 Scalene
- 세 각의 합이 180이 아닌 경우에는 Error
를 출력하는 프로그램을 작성하시오.
🔎 풀이
입력받은 수를 리스트에 저장한 뒤 정해진 조건에 맞추어 출력하면 된다.
💻 코드
nums = []
isosceles = False
for i in range(3):
n = int(input())
if n in nums:
isosceles = True
nums.append(n)
if nums[0] == 60 and nums[1] == 60 and nums[2] == 60:
print("Equilateral")
elif sum(nums) == 180 and isosceles:
print("Isosceles")
elif sum(nums) == 180 and not isosceles:
print("Scalene")
else:
print("Error")