본문 바로가기

취업준비 - 코테 , 면접/알고리즘(코테) 공부

백준 14681번 (조건문)

(문제)

 

(풀이)

 

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();

        if(x > 0) {
            if(y > 0) {
                System.out.println(1);
            }
            else { // (y < 0)
                System.out.println(4);
            }
        }
        else { // (x < 0)
            if(y > 0) {
                System.out.println(2);
            }
            else { // (y < 0)
                System.out.println(3);
            }
        }
    }
}