본문 바로가기
백준

[백준] 10101번 : 삼각형 외우기 - 파이썬(Python) - 우당탕탕 개발자 되기 프로젝트

by 우당탕탕 개발자 2023. 10. 29.
728x90
반응형

 

 

10101번: 삼각형 외우기

문제의 설명에 따라 Equilateral, Isosceles, Scalene, Error 중 하나를 출력한다.

www.acmicpc.net

 

1. 문제 설명

2. 풀이과정

  1. sys.stdin.readline() 함수를 사용하기 위해 sys 모듈을 불러온다. import sys
  2. 삼각형의 세 각의 크기를 입력받는다. a = int(sys.stdin.readline())
  3. b = int(sys.stdin.readline())
  4. c = int(sys.stdin.readline())
  5. 세 각의 합이 180일 경우 if (a + b + c == 180)
  6. 세 각의 크기가 모두 같으면 if (a == b == c)
  7. Equilateral를 출력한다. print('Equilateral')
  8. 반면 세 각의 크기가 모두 같지 않고 else
  9. 두 각이 같을 경우 if (a == b) and (b == c) and (c == a)
  10. Isosceles를 출력한다. print('Isosceles')
  11. 세 각의 크기가 모두 다를 경우 else
  12. Scalene를 출력한다. print('Scalene')
  13. 반면 세 각의 합이 180이 아닐 경우 else
  14. 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
반응형