AcWing 662. 点的坐标 - Java
原题链接
简单
作者:
KYCygni
,
2021-03-09 15:00:36
,
所有人可见
,
阅读 236
Java 代码
import java.util.Scanner;
public class Main
{
public static boolean isOrigin(double x, double y)
{
return x == 0 && y == 0;
}
public static boolean isOnX(double x, double y)
{
return x != 0 && y == 0;
}
public static boolean isOnY(double x, double y)
{
return x == 0 && y != 0;
}
public static boolean isQ1(double x, double y)
{
return x > 0 && y > 0;
}
public static boolean isQ2(double x, double y)
{
return x < 0 && y > 0;
}
public static boolean isQ3(double x, double y)
{
return x < 0 && y < 0;
}
public static boolean isQ4(double x, double y)
{
return x > 0 && y < 0;
}
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
double x = cin.nextDouble();
double y = cin.nextDouble();
if (isOrigin (x, y))
System.out.println ("Origem");
else if (isOnX (x, y))
System.out.println ("Eixo X");
else if (isOnY (x, y))
System.out.println ("Eixo Y");
else if (isQ1 (x, y))
System.out.println ("Q1");
else if (isQ2 (x, y))
System.out.println ("Q2");
else if (isQ3 (x, y))
System.out.println ("Q3");
else if (isQ4 (x, y))
System.out.println ("Q4");
}
}