728x90
출처-https://www.acmicpc.net/problem/14681
14681번: 사분면 고르기
문제 흔한 수학 문제 중 하나는 주어진 점이 어느 사분면에 속하는지 알아내는 것이다. 사분면은 아래 그림처럼 1부터 4까지 번호를 갖는다. "Quadrant n"은 "제n사분면"이라는 뜻이다. 예를 들어, 좌
www.acmicpc.net
728x90
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan=new Scanner(System.in);
int x=scan.nextInt();
int y=scan.nextInt();
if ((x>0)&&(y>0))
System.out.println("1");
else if ((x<0)&&(y>0))
System.out.println("2");
else if ((x<0)&&(y<0))
System.out.println("3");
else
System.out.println("4");
}
}
728x90
'Problem Solving > BOJ' 카테고리의 다른 글
[백준, BOJ 15552] 빠른 A+B (java) (0) | 2020.08.21 |
---|---|
[백준, BOJ 2884] 알람 시계 (java) (0) | 2020.08.20 |
[백준, BOJ 2753] 윤년 (java) (0) | 2020.08.20 |
[백준, BOJ 9498] 시험 성적 (java) (0) | 2020.08.20 |
[백준, BOJ 1330] 두 수 비교하기 (java) (0) | 2020.08.20 |