[求助] 微积分问题
#include <stdio.h>#include <math.h>
double integral(double(*p)(double),double a,double b,int n)
{
int i;
double x,h,s;
h=(a+b)/n;
x=a;
s=0;
for(i=0;i<n;i++)
{
x=x+h;
s=s+(*p)(x)*h;
}
return s;
}
void main()
{
integral(sin,0,1,1000);
printf("%f\n",sin);
}
求sin函数的面积。结果有问题~~~