본문 바로가기

자바

백준 알고리즘 - 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 && y > 0) {
			System.out.print(1);
		} else if (x < 0 && y > 0) {
			System.out.print(2);
		} else if (x < 0 && y < 0) {
			System.out.print(3);
		} else {
			System.out.print(4);

		}
	}
}

이번 문제는 딱히 어렵지 않았다.. 문제 조건의 설명이 너무 잘 돼있었기 때문에 천천히 읽으면서 조건을 적으면 되는 문제였다!