• 2003 求绝对值


    2003    求绝对值

    Problem Description
    求实数的绝对值。
     

     

    Input
    输入数据有多组,每组占一行,每行包含一个实数。
     


    Output
    对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。
     


    Sample Input
    123
    -234.00
     


    Sample Output
    123.00
    234.00
    #include<stdio.h>
    int main()
    {
        double a;
        while(scanf("%lf",&a)!=EOF)
        {
            if(a<0)
            {
                a=(-1)*a;
                printf("%.2lf
    ",a);
            }
            else printf("%.2lf
    ",a);
        }
        return 0;
    }

    注:水题一道,可以锻炼基础知识的熟练度。

  • 相关阅读:
    v-for基本使用
    SSH
    Git 命令
    bower笔记
    gulp使用例子
    yeoman使用例子
    grunt搭建
    不会误解的名字
    Python 多线程 多进程
    Python 协程
  • 原文地址:https://www.cnblogs.com/wengweng/p/6707088.html
Copyright © 2020-2023  润新知