代码个人制作,如需解析请私信。
2-1
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double x,y;
scanf("%lf",&x);
if (x>=0){
y=sqrt(x);
printf("f(%.2lf) = %.2lf",x,y);
}
else{
y=pow(x+1,2)+2*x+1/x;
printf("f(%.2lf) = %.2lf",x,y);
}
return 0;
}
2-2
#includ