HDU_oj_2003 求绝对值

Problem Description
 
求实数的绝对值。
 
Input
输入数据有多组,每组占一行,每行包含一个实数。
 
Output
对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。
 
Sample Input
123
-234.00
 
Sample Output
123.00
234.00
 
分析:
注意点:
 
 
 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     double r;
 7     while(cin>>r)
 8     {
 9         if(r<0)
10         r=-r; 
11         printf("%.2f\n",r);
12     }
13 }

 

 
posted @ 2017-12-03 18:48  T丶jl  阅读(133)  评论(0编辑  收藏  举报