Here we are going to solve the problem 1115-Quadrant. We will divide this process into certain sections to make it easier. And it will also help us solve other problems faster.
The problem:
Write a program to read the coordinates (X, Y) of an indeterminate number of points in the Cartesian system. For each point write the quadrant to which it belongs. The program finishes when at least one of two coordinates is NULL (in this situation without writing any message).
Input
The input contains several test cases. Each test case contains two integer numbers.
Output
For each test case, print the corresponding quadrant to which these coordinates belong, as in the example.
Understanding the problem:
Write a program to read the coordinates (X, Y) of an indeterminate number of points in the Cartesian system.
In this line, it is said that you have to read the coordinates of some points with the x-axis and y-axis values. The number of points is indeterminate. So we understand that we don't know how many inputs will be given. But every time there will be two numbers (X and Y). This tells us to create a loop. But running an infinite loop is not very good. In this case, we will run this loop maximum of 100 times. So what we get is:
For each point write the quadrant to which it belongs. The program finishes when at least one of two coordinates is NULL (in this situation without writing any message).
Now that we took the inputs (X Y), we have to analyze them. Here it says to search for the quadrant the point belongs to. And when one of the axis values will be 0 we will break the loop which will end the program. We can see in the image below the values of x and y in each quadrant.
So our conditions for checking which quadrant the point is in will be:
Now that we understand the problem we can write the program. The full Solution is: