[백준] 10101 삼각형 외우기 Python
2024. 6. 22. 00:45ㆍPython/백준
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")
'Python > 백준' 카테고리의 다른 글
[백준] 10773 제로 Python (2) | 2024.06.23 |
---|---|
[백준] 5073 삼각형과 세 변 Python (1) | 2024.06.22 |
[백준] 9063 대지 Python (1) | 2024.06.22 |
[백준] 15894 수학은 체육과목 입니다 Python (1) | 2024.06.22 |
[백준] 18258 큐 2 Python (0) | 2024.06.21 |