两点之间的距离1636050052王智霞

import java.util.Scanner;

public class Distance

{     

   public static void main(String[] args)  

    {  

       double a;   

      Scanner input =new Scanner(System.in);   

      System.out.print("Enter x1 and y1:");

        double x1=input.nextDouble();   

      double y1=input.nextDouble();   

      System.out.print("Enter x2 and y2:");

        double x2=input.nextDouble();   

      double y2=input.nextDouble();

        a=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);   

      System.out.println("The distance between the two points is:"+Math.pow(a,0.5));

     }

}

posted on 2017-09-18 12:19  老张的小迷妹儿  阅读(215)  评论(0)    收藏  举报

导航