//求两点之间的距离. import java.util.Scanner; //import java.lang.Math; class TestLength { public static void main(String[] args) { double x1,x2,y1,y2; Scanner in = new Scanner(System.in); System.out.println("Please input four integer numbers:"); x1 = in.nextDouble(); y1 = in.nextDouble(); x2 = in.nextDouble(); y2 = in.nextDouble(); //调用函数,求两点之间的距离。 double l = Length(x1,y1,x2,y2); System.out.println("两点之间的距离是:"+l); } public static double Length(double x1,double y1,double x2,double y2) { double n; n = Math.sqrt(((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); return n; } }