Algorithm/JAVA

[Java] 14681

SPIGYEN 2021. 8. 31. 23:16

https://www.acmicpc.net/problem/14681

 

14681번: 사분면 고르기

점 (x, y)의 사분면 번호(1, 2, 3, 4 중 하나)를 출력한다.

www.acmicpc.net

import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		
		int x = in.nextInt();
		int y = in.nextInt();
		
		if(x > 0) {
			if (y > 0)
				System.out.print(1);
			else
				System.out.print(4);
		}
		else {
			if (y > 0)
				System.out.print(2);
			else
				System.out.print(3);
		}
	}
}