#include<stdio.h> #include<math.h> void main () { double x,y; printf("输入x:"); scanf("%lf",&x); if(x<-2){ y=x*x; } else if(x>2){ y=sqrt(x*x+x+1); } if((x>=-2)&&(x<=2)){ y=2+x; } printf("y=f(%f)=%.2f\n",x,y); }
#include<stdio.h> #include<math.h> void main () { double x,y; printf("输入x:"); scanf("%lf",&x); if(x<-2){ y=x*x; } else if(x>2){ y=sqrt(x*x+x+1); } if((x>=-2)&&(x<=2)){ y=2+x; } printf("y=f(%f)=%.2f\n",x,y); }
转载于:https://www.cnblogs.com/lvdingding13588022785/p/3398524.html