Pick the Quadrant
InterviewTime limit1sMemory limit512 MB
Read the x and y coordinates of a nonzero point and print which of the four quadrants it lies in.
- Level
Easy1 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Given a point, decide which quadrant it lies in. The quadrants are numbered 1 through 4 as in the picture below. "Quadrant n" in the picture means the n-th quadrant.

For example, point A at has a positive x coordinate and a positive y coordinate, so it lies in quadrant 1. Point B has a negative x coordinate and a positive y coordinate, so it lies in quadrant 2.
Write a program that reads the coordinates of a point and reports its quadrant. Both coordinates are either positive or negative, and zero never appears.
Input
The first line contains an integer . (, )
The second line contains an integer . (, )
Output
Print the number of the quadrant that contains the point . The value is one of 1, 2, 3, 4.