상세 컨텐츠

본문 제목

백준 14681번

백준 알고리즘 풀이

by 발발개발 2020. 12. 14. 13:26

본문

원본 : 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 sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		if (x > 0) {
			if (y > 0) {
				System.out.println("1");
			} else {
				System.out.println("4");
			}
		} else {
			if (y > 0) {
				System.out.println("2");
			} else {
				System.out.println("3");
			}
		}
	}

}

'백준 알고리즘 풀이' 카테고리의 다른 글

백준 2739번  (0) 2020.12.14
백준 2884번  (0) 2020.12.14
백준 2753번  (0) 2020.12.14
백준 9498번  (0) 2020.12.14
백준 1330번  (0) 2020.12.14

관련글 더보기

댓글 영역