URI ONLINE JUDGE SOLUTION 1041 - Coordinates of a Point

Problem


Write an algorithm that reads two floating values (x and y), which should represent the coordinates of a point in a plane. Next, determine which quadrant the point belongs, or if you are over one of the Cartesian axes or the origin (x = y = 0).

If the point is at the origin, write the message "Origem".
If the point is over X axis write "Eixo X", else if the point is over Y axis write "Eixo Y".

Input

The input contains the coordinates of a point.

Output


The output should display the quadrant in which the point is.

sample input output


Solution

#include<stdio.h>
int main()
{
    double x,y;
    scanf("%lf%lf",&x,&y);
    if(x == 0 & y == 0)
        printf("Origem\n");
    if(y == 0 && x!=0)
        printf("Eixo X\n");
    if(x == 0 && y!=0)
        printf("Eixo Y\n");
    if(x > 0 && y > 0)
        printf("Q1\n");
    if(x < 0 && y > 0)
        printf("Q2\n");
    if(x < 0 && y < 0)
        printf("Q3\n");
    if(x > 0 && y < 0)
        printf("Q4\n");
    return 0;

}

How To Solve : Here you have to just check a point with it's axis values(x and y) and make a discussion where the point belongs. I think,you all have already known the basic geometry about axis.So I did not discuss it. Then apply your concept with if -else condition. This is a very easy problem.First Try yourself then see my code and compare it with your's.Don't copy paste it.Take time if you fail,it will help you next day.Happy coding.

Comments

Popular posts from this blog

URI ONLINE JUDGE SOLUTION 1021 - Banknotes and Coins

URI ONLINE JUDGE SOLUTION 1040 - Average 3

URI ONLINE JUDGE SOLUTION 1036 - Bhaskara's Formula