求助,关于指针指向函数语法错误问题
下面是源码:#include<stdio.h>//一个函数既可以计算抛物线,又可以计算余弦函数,用指针函数实现。
#include<math.h>
double y(double);
double cos(double);
double total(double (*f)(),double min,double max,double step);
int main()
{
total(y,0.0,2.0,0.5);//返回y(x),x=0,0.5,1,1.5,2
printf("cos is:\n");
total(cos,0.0,2.0,0.5);返回cos(x),x=0,0.5,1,1.5,2
return 0;
}
double y(double x)
{
return(2*x*x-x+1);
}
double total(double (*f)(),double min,double max,double step)
{
double a=0,value;
for(a=min;a<=max;a+=step)
{
value=(*f)(a);
printf("%5.2f,%5.4f\n",a,value);
}
return 0;
}