CS/BaekJoon

[BaekJoon] 백준 14681번 사분면 고르기 - Java

Bell91 2023. 12. 25. 17:43
반응형

🎈문제

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

 

💬설명

  • 두 숫자를 입력받아 몇사분면인지 출력해보자
  • if, else if, else 조건문을 살펴보자

 

⌨️ CODE

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.println("1");
		}else if(x>0 && y<0) {
			System.out.println("4");
		}else if(x<0 && y<0) {
			System.out.println("3");
		}else {
			System.out.println("2");
		}
	}
}
반응형