#include<stdio.h> #include<math.h>//调用数学函数 int main(void) { int x; double y; printf("Enter x:"); scanf("%d",&x); if(x<-2){ y=x*x; } if((x>=-2)&&(x<=2)){ y=2+x; } else(x>2);{ y=sqrt(x*x+x+1);//aqrt为平方根的计算方法 } printf("%lf ",y); return 0; }