输入一个浮点数,输出他的绝对值,保留两位小数。不准用数学函数。
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, char *argv[])
{
double x;
scanf("%lf",&x);
if( x < 0 )
x=-x;
printf("%.2f",x);
system("pause");
return EXIT_SUCCESS;
}