首页 > 代码库 > NYOJ题目101两点距离

NYOJ题目101两点距离

技术分享

----------------------------------------

 

技术分享

 

AC代码:

 1 import java.util.Scanner; 2  3 public class Main { 4  5     public static void main(String[] args) { 6          7         Scanner sc=new Scanner(System.in); 8          9         int times=sc.nextInt();10         while(times-->0){11             double x1=sc.nextDouble();12             double y1=sc.nextDouble();13             double x2=sc.nextDouble();14             double y2=sc.nextDouble();15             double ans=getDistance(x1,y1,x2,y2);16             System.out.printf("%.2f\n",ans);17         }18         19     }20     21     public static double getDistance(double x1,double y1,double x2,double y2){22         return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));23     }24     25 }

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=101

 

NYOJ题目101两点距离