求两点间的距离

import java.util.Scanner;
class Point{
    double x;
    double y;
}
public class Test01 {
    public static void main(String[] args){
    Point a=new Point();
    Point b=new Point();
    Scanner scanner=new Scanner(System.in);
    a.x=scanner.nextDouble();
    a.y=scanner.nextDouble();
    b.x=scanner.nextDouble();
    b.y=scanner.nextDouble();
    System.out.println("结果是:");
    System.out.printf("%.4f",Math.pow(Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2),0.5));

    }
}

 

posted @ 2022-04-04 00:18  HzzzzLi  阅读(24)  评论(0)    收藏  举报