알고리즘/백준알고리즘
[백준 알고리즘/Python3]14681 사분면 고르기
wonin
2021. 7. 20. 10:00
문제
Python 코드
x = int(input())
y = int(input())
if(x>0):
if(y>0):
print(1)
else:
print(4)
else:
if(y>0):
print(2)
else:
print(3)
x축을 기준으로 오른쪽은 1,4분면, 왼쪽은 2,3 분면으로 나눴다.
다른사람 코드를 보니
a = int(input())
b = int(input())
if a>0 and b>0:
print(1)
elif a<0 and b>0:
print(2)
elif a<0 and b<0:
print(3)
else:
print(4)
이런식으로 x,y 각각 if, elif문으로 분기를 나누는 것도 좋아 보인다.
728x90