
用if...else就可以
#include <math.h>
void main()
{
double x,y;
scanf("%lf",&x);
bool b = true;
if(x>=-10 && x<=4)
y = fabs(x-2);
else if(x>=5 && x<=7)
y = x+10;
else if(x>=8 && x<=12)
y = x*x*x*x;
else
{
printf("NO answer);
b = false;
}
if(b)
printf("y=%.2lf",y);
}