📜  math.pow(x2-x1,2) - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:06.594000             🧑  作者: Mango

代码示例1
import java.util.Scanner;

public class CoordinateGeometry {
  public static void main(String [] args) {
  Scanner scnr = new Scanner(System.in);
  double x1;
  double y1;
  double x2;
  double y2;
  double pointsDistance;
  double xDist;
  double yDist;

  pointsDistance = 0.0;
  xDist = 0.0;
  yDist = 0.0;

  x1 = scnr.nextDouble();
  y1 = scnr.nextDouble();
  x2 = scnr.nextDouble();
  y2 = scnr.nextDouble();

  poinsDistance = Math.sqrt(Math.pow(x2 - x1, 2) + (Math.pow(y2 - y1, 2));

  System.out.println(pointsDistance);
  }
}