#include <iostream>
#include<math.h>
double function(double x)
{
double result = 0;
if(fabs(x) <= 1)
{
result = fabs(x - 1.0) - 2;
}else
{
result = 1.0 / (1 + x*x);
}
return result;
}
int main()
{
double i = function(function(-3));
std::cout << i;
system("pause");
return 0;
}
保留2位小数你百度一下就行了