Tutte le sfide
Facile 0 risolte 0% di accettazione

Point Quadrant

Find which quadrant a point lies in.

Problema

The x and y axes split the plane into four quadrants: Q1 (x > 0, y > 0), Q2 (x < 0, y > 0), Q3 (x < 0, y < 0) and Q4 (x > 0, y < 0). Points on an axis belong to no quadrant.

Implement point_quadrant(x, y).

Input

x: The x coordinate. y: The y coordinate.

Output

Return "Q1", "Q2", "Q3" or "Q4"; "X-axis" or "Y-axis" for points on an axis; or "Origin" for (0, 0).

Vincoli

-1,000,000 ≤ x, y ≤ 1,000,000

Esempi

Esempio 1
Input:
x = -3
y = 4

Output atteso:
expected = "Q2"
Input:
long long x = -3;
long long y = 4;

Output atteso:
std::string expected = "Q2";
Input:
long x = -3;
long y = 4;

Output atteso:
string expected = "Q2";

Spiegazione

x is negative and y is positive, so the point is in Q2.

Esempio 2
Input:
x = 5
y = 0

Output atteso:
expected = "X-axis"
Input:
long long x = 5;
long long y = 0;

Output atteso:
std::string expected = "X-axis";
Input:
long x = 5;
long y = 0;

Output atteso:
string expected = "X-axis";

Spiegazione

y is 0, so the point lies on the X-axis.

Riferimenti

Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.

Impara dagli altri

Soluzioni della community

Nessuna soluzione pubblicata. Risolvi questa sfida per condividere la prima.