题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2003
//C++代码
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
double a;
while(cin>>a) cout<<fixed<<setprecision(2)<<fabs(a)<<endl;
return 0;
}
本文提供了一道来自杭电OJ的2003号题目的解决方案,采用C++语言实现,主要功能为读取输入的浮点数并输出其绝对值,精确到小数点后两位。
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2003
//C++代码
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
double a;
while(cin>>a) cout<<fixed<<setprecision(2)<<fabs(a)<<endl;
return 0;
}

被折叠的 条评论
为什么被折叠?