水1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31650113/article/details/78278601

hdu2001,控制小数位数

import java.util.Scanner;
import java.math.*;
import java.text.DecimalFormat;

public class j2001 {
    public static void main(String[] args){
        int x1,y1,x2,y2;
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            double x11 = sc.nextDouble();
            double y11 = sc.nextDouble();
            double x22 = sc.nextDouble();
            double y22 = sc.nextDouble();
            double ans = Math.sqrt((x11-x22)*(x11-x22)+(y11-y22)*(y11-y22));
            DecimalFormat df = new DecimalFormat("#0.00");//控制小数位数两位
            System.out.println(df.format(ans));
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_31650113/article/details/78278601