HDOJ 2003 求绝对值

来源:互联网 发布:电脑桌面淘宝下载 编辑:程序博客网 时间:2024/06/06 01:03

      求绝对值,注意打印的精度。

/** * Created by YangYuan on 2017/12/8. */public class Problem2003{    public static void main(String[] args)    {        Scanner scanner = new Scanner(System.in);        DecimalFormat df = new DecimalFormat("0.00");        while (scanner.hasNext())        {            double x = scanner.nextDouble();            if (x < 0)                x = -x;            System.out.println(df.format(x));        }    }}

原创粉丝点击