포스트

점의 위치 구하기

https://school.programmers.co.kr/learn/courses/30/lessons/120841

문제 문제

  • 문제 풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class Solution {
    public int solution(int[] dot) {
        int x = dot[0];
        int y = dot[1];

        if (x > 0 && y > 0) { // x, y 모두 양수인 경우
            return 1;
        } else if (x < 0 && y > 0) { // x가 음수, y가 양수인 경우
            return 2;
        } else if (x < 0 && y < 0) { // x, y 모두 음수인 경우
            return 3;
        } else { // x가 양수, y가 음수인 경우
            return 4;
        }
    }
}
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.