用指向函数的指针作函数参数,求分段函数当x<0时,y=x+2;当0≤x<5时,y=3x-1;当x≥5时,y=x(x-1)
问题描述:
用指向函数的指针作函数参数,求分段函数当x<0时,y=x+2;当0≤x<5时,y=3x-1;当x≥5时,y=x(x-1)
答
double fun1(double x){return x+2;}double fun2(double x){return 3*x-1;}double fun3(double x){return x*(x-1);}void main(){double x;scanf("%lf",&x);double (*fun)(double);//函数指针if(x