展开全部
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<0) fun = fun1;
else if(x<5) fun = fun2;
else fun = fun3;
double result = fun(x); //通过函数指针调用
printf("%lf",result);
}
{
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<0) fun = fun1;
else if(x<5) fun = fun2;
else fun = fun3;
double result = fun(x); //通过函数指针调用
printf("%lf",result);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询