练习2 B题

 
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
 

Description

求实数的绝对值。
 

Input

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

Output

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

Sample Input

123
-234.00
 

Sample Output

123.00
234.00
 
 
#include<stdio.h>
#include<math.h>
int main()
{
    double x;
    while(scanf("%lf",&x)!=EOF)
    {
        if(x<0)
        {
            x =-x;
        }
        printf("%.2lf
",x);
    }
    return 0;
}
 
原文地址:https://www.cnblogs.com/hfc-xx/p/4903419.html