c语言高手请进来 急需帮忙....在线....

来源:百度知道 编辑:UC知道 时间:2024/05/25 23:55:49
#include <stdio.h>
#include <math.h>
#define PI 3.1415926
double y(double);
double cos(double);
double table(double(*f)(),double min,double max,double step);
void main()
{
printf("table of y(x)=2*x*x-x+1 \n\n");
table(y,0.0,2.0,0.5);
printf("\ntable of cos(x)\n\n");
table(cos,0.0,PI,0.5);
}
double table(double(*f)(),double min,double max,double step)
{
double a,value;
for(a=min;a<=max;a+=step)
{
value=(*f)(a);
printf("%5.2f %10.4f \n",a,value);
}
}
double y(double x)
{ return(2*x*x-x+1); }

怎么改/????
用tc 可以编出来
可是我用vc 却发现三个错误..
不明白在这里

table(cos,0.0,PI,0.5);
运行到这里出问题了

double table(double(*f)(),double min,double max,double step);
把double改成void,你没有返回值。另外,在主函数最后面加一个getch();
就能运行

没什么大错误啊