#include<stdio.h> #include<math.h> int main(void) { double y,x; y=0; printf("输入x:"); scanf("%lf",&x); if(x>2){ y=y+sqrt(x*x+x+1); } else if((x>=-2)&&(x<=2)){ y=y+2+x; } else{ y=y+x*x; } printf("y=%.3f",y); return 0; }