hdu_2001 计算两点间的距离

来源:互联网 发布:c删除数组中的一个元素 编辑:程序博客网 时间:2024/06/11 22:03
import java.text.DecimalFormat;import java.util.*;public class Main {    public static void main(String[] args) {        Scanner scan = new Scanner(System.in);        // 判断是否还有输入        while (scan.hasNext()){            double x1 = scan.nextDouble();            double y1 = scan.nextDouble();            double x2 = scan.nextDouble();            double y2 = scan.nextDouble();            double dis = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));            DecimalFormat df = new DecimalFormat("#0.00");            System.out.println(df.format(dis));        }    }}
原创粉丝点击