【水题】hdu2003 求绝对值

水题啊,求绝对值,要么去弄个if分支,或者直接使用<cmath>的函数fabs求绝对值;代码如下:

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main ()
{
double a;
while(cin>>a)
{
    cout<<fixed<<setprecision(2)<<fabs(a)<<endl;
}
return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41627235/article/details/82780687