PAT:分支-16. 计算分段函数(10) AC
#include<stdio.h>
#include<math.h>
int main()
{
double x;
scanf("%lf",&x);
if(x>=0)
printf("f(%.2lf) = %.2lf\n",x,pow(x,0.5));
else
printf("f(%.2lf) = %.2lf\n",x,(pow(x+1,2))+2*x+1/x);
return 0;
}
#include<stdio.h>
#include<math.h>
int main()
{
double x;
scanf("%lf",&x);
if(x>=0)
printf("f(%.2lf) = %.2lf\n",x,pow(x,0.5));
else
printf("f(%.2lf) = %.2lf\n",x,(pow(x+1,2))+2*x+1/x);
return 0;
}