import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Point p1 = new Point(scanner.nextDouble(), scanner.nextDouble());
Point p2 = new Point(scanner.nextDouble(), scanner.nextDouble());
int quadrant1 = p1.getQuadrant();
int quadrant2 = p2.getQuadrant();
double distance = p1.calDistance(p2);
System.out.println(quadrant1 + " " + quadrant2 + " " + Math.round(distance));
}
}
class Point {
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public int getQuadrant() {
if (x > 0 && y > 0) {
return 1;
} else if (x < 0 && y > 0) {
return 2;
} else if (x < 0 && y < 0) {
return 3;
} else if (x > 0 && y < 0) {
return 4;
} else {
return 0;
}
}
public double calDistance(Point p) {
double dx = x - p.getX();
double dy = y - p.getY();
return Math.sqrt(dx * dx + dy * dy);
}
public double getX() {
return x;
}
public double getY() {
return y;
}
}
1. First create two Point objects p1 and p2 in the main function and read the coordinates of the two points respectively from the standard input.
2. Then call the getQuadrant() method of p1 and p2, respectively, to find the quadrants where the two points are located.
3. Next, call p1's calDistance() method to calculate the distance between the two points and round it to an integer.
4. Finally, output the three values in sequence.
Note: The calDistance() method calculates the inherit distance from two points based on their coordinate difference, i.e.
√
(
x
1
−
x
2
< /span>
< 2
+
(
y
1
−
y
< /span>
2
where $x_1$and $y_1$are the coordinates of the first point and $x_2$and $y_2$are the coordinates of the second point. Finally, the Math.round() method is used to round the result to an integer.