반응형
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 |
'Algorithm' 카테고리의 다른 글
(C++) - 백준(BOJ) 15802번 : 타노스 답 (0) | 2019.11.19 |
---|---|
(C++) - 백준(BOJ) 17009번 : Winning Score (0) | 2019.11.19 |
(C++) - 백준(BOJ) 16486번 : 운동장 한 바퀴 (0) | 2019.11.18 |
(C++) - 백준(BOJ) 16431번 : 베시와 데이지 (0) | 2019.11.18 |
(C++) - 백준(BOJ) 17388번 : 와글와글 숭고한 (0) | 2019.11.16 |