ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Point Quadrant

Find which quadrant a point lies in.

โจทย์

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).

เงื่อนไข

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

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
x = -3
y = 4

ผลลัพธ์ที่คาดหวัง:
expected = "Q2"
อินพุต:
long long x = -3;
long long y = 4;

ผลลัพธ์ที่คาดหวัง:
std::string expected = "Q2";
อินพุต:
long x = -3;
long y = 4;

ผลลัพธ์ที่คาดหวัง:
string expected = "Q2";

คำอธิบาย

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

ตัวอย่างที่ 2
อินพุต:
x = 5
y = 0

ผลลัพธ์ที่คาดหวัง:
expected = "X-axis"
อินพุต:
long long x = 5;
long long y = 0;

ผลลัพธ์ที่คาดหวัง:
std::string expected = "X-axis";
อินพุต:
long x = 5;
long y = 0;

ผลลัพธ์ที่คาดหวัง:
string expected = "X-axis";

คำอธิบาย

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

แหล่งอ้างอิง

โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก