求绝对值

求绝对值

Problem : 412

Time Limit : 1000ms

Memory Limit : 65536K

description

求实数的绝对值。

input

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

output

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

sample_input

123
-234.00

sample_output

123.00
234.00

hint

 

source

hdu

 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    double a;
    while(scanf("%lf",&a)!=-1)
    {
        printf("%.2lf\n",fabs((double)a));
    }
    return 0;
}

新函数!!注意头文件!!

int abs(int i); 求整型的绝对值
double fabs (double);求实型的绝对值
posted @ 2015-11-27 21:07  邻家那小孩儿  阅读(175)  评论(0编辑  收藏  举报