jP61 2.15

时间:2024-10-15 18:36:14

import java.util.Scanner;

public class Distance

{

  public static void main(String[] args)

  {    

    Scanner input=new Scanner(System.in);

    System.out.print("请输入第一个点的坐标,x与y用空格隔开:");

    double x1=input.nextDouble();

    double y1=input.nextDouble();

    System.out.print("请输入第二个点的坐标,x与y用空格隔开:");

    double x2=input.nextDouble();   double y2=input.nextDouble();

    double distance=Math.pow(((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)),0.5);

    System.out.println("这两个点之间的距离为:"+distance);

  }

}