Competitive Programming Solutions

GitHub
back to dashboard

Q. Coordinates of a Point

Codeforces - Sheet #1 (Data type - Conditions) · limit: 1s · memory: 256MB · view on codeforces

input

4.5 -2.2

output

Q4
Main.java
static void solve() {

        // Write your solution here
        double x = in.nextDouble();
        double y = in.nextDouble();
        if(x > 0){
            if (y > 0) out.print("Q1");
            else if (y < 0) out.print("Q4");
            else out.print("Eixo X");
        }
        else if (x < 0) {
            if (y > 0) out.print("Q2");
            else if (y < 0) out.print("Q3");
            else out.print("Eixo X");
        }
        else{
            if (y > 0) out.print("Eixo Y");
            else if (y < 0) out.print("Eixo Y");
            else out.print("Origem");
        }

    }