牛顿插值多项式,我这是哪里错了啊
#include<stdio.h>#define maxsize 100
int main(void)
{
double x[maxsize],y[maxsize],m,sum,p;
int i,k,n;
printf("please input m=\n");
scanf("%lf",&m);
printf("please input n=\n");
scanf("%d",&n);
printf("please input x[i]=\n");
for(i=0;i<=n;i++)
{
printf("x[%d]=",i);
scanf("%lf",&x[i]);
}
printf("please input y[i]=\n");
for(i=0;i<=n;i++)
{
printf("y[%d]=",i);
scanf("%lf",&y[i]);
}
for(k=0;k<=n;k++)
{
for(i=n;i>=k;i--)
y[i]=(y[i]-y[i-1])/(x[i]-x[i-k]);
}
sum=y[0];
for(i=1;i<=n;i++)
{
p=1;
for(k=0;k<=i-1;k++)
{
p=p*(m-x[i]);
sum+=p*y[i];
}
}
printf("sum=%lf",sum);
return 0;
}