백준
[백준] 10101번 : 삼각형 외우기 - 파이썬(Python) - 우당탕탕 개발자 되기 프로젝트
우당탕탕 개발자
2023. 10. 29. 14:30
728x90
반응형
10101번: 삼각형 외우기
문제의 설명에 따라 Equilateral, Isosceles, Scalene, Error 중 하나를 출력한다.
www.acmicpc.net
1. 문제 설명
2. 풀이과정
- sys.stdin.readline() 함수를 사용하기 위해 sys 모듈을 불러온다. import sys
- 삼각형의 세 각의 크기를 입력받는다. a = int(sys.stdin.readline())
- b = int(sys.stdin.readline())
- c = int(sys.stdin.readline())
- 세 각의 합이 180일 경우 if (a + b + c == 180)
- 세 각의 크기가 모두 같으면 if (a == b == c)
- Equilateral를 출력한다. print('Equilateral')
- 반면 세 각의 크기가 모두 같지 않고 else
- 두 각이 같을 경우 if (a == b) and (b == c) and (c == a)
- Isosceles를 출력한다. print('Isosceles')
- 세 각의 크기가 모두 다를 경우 else
- Scalene를 출력한다. print('Scalene')
- 반면 세 각의 합이 180이 아닐 경우 else
- Error를 출력한다. print('Error')
반응형
3. 소스코드
import sys
a = int(sys.stdin.readline())
b = int(sys.stdin.readline())
c = int(sys.stdin.readline())
if (a + b + c == 180):
if (a == b == c):
print('Equilateral')
else:
if (a == b) or (b == c) or (c == a):
print('Isosceles')
else:
print('Scalene')
else:
print('Error')
728x90
반응형