본문 바로가기

Algorithm

(C++) - 백준(BOJ) 14681번 : Quadrant Selection

반응형

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

 

14681번: Quadrant Selection

A common problem in mathematics is to determine which quadrant a given point lies in. There are four quadrants, numbered from 1 to 4, as shown in the diagram below: For example, the point A, which is at coordinates (12, 5) lies in quadrant 1 since both its

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;
    if (x > 0 && y > 0)
        cout << 1 << '\n';
    else if (x > 0 && y < 0)
        cout << 4 << '\n';
    else if (x < 0 && y > 0)
        cout << 2 << '\n';
    else
        cout << 3 << '\n';
}
cs