사분면 고르기 (14681)

921 단어 백준OJ백준OJ

Java 11

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        int y = Integer.parseInt(br.readLine());
        br.close();

        StringBuilder sb = new StringBuilder();

        if (x > 0 && y > 0) {
            sb.append("1");
        }
        else if (x < 0 && y > 0) {
            sb.append("2");
        }
        else if (x < 0 && y < 0) {
            sb.append("3");
        }
        else {
            sb.append("4");
        }

        System.out.print(sb);

    }
}

좋은 웹페이지 즐겨찾기