Problem Description
求实数的绝对值。
Input
输入数据有多组,每组占一行,每行包含一个实数。输入文件直到EOF为止!
Output
对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。
Example Input
123 -234.00
Example Output
123.00234.00
答案:
#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { double a; while(cin >> a) { cout<< fixed <<setprecision(2) << abs(a) << endl; } return 0; }