hdu oj 2003

求絕對值

Problem Description

求實數的絕對值。
 Input
輸入數據有多組,每組佔一行,每行包含一個實數。
 Output
對於每組輸入數據,輸出它的絕對值,要求每組數據輸出一行,結果保留兩位小數。
 Sample Input
123 -234.00
 Sample Output
123.00 234.00

my code:

#include<stdio.h>
#include<math.h>
int main(){
    double r;
    while(~scanf("%lf",&r)){
        printf("%.2lf\n",fabs(r));
        }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章