求大神帮忙,C语言程序总有一个error,实在找不着错误在哪儿,求指点,谢!!!!!!
#include<math.h>#include<stdio.h>#definen1main(){inti,j;floata[4]={-0.25,-0.5,-0.75,0...
#include <math.h>
#include <stdio.h>
#define n 1
main()
{
int i,j;
float a[4]={-0.25,-0.5,-0.75,0},b[4]={0.33493750,-0.02475000,-0.07181250,1.101},x[n+1],y[n+1],l[n+1],x=-1.0/3,y=0;
for(i=0;i<=n;i++)
{
x[i]=a[i];
y[i]=b[i];
l[i]=1;
}
for(i=0;i<=n;i++)
{
for(j=0;j<=n;j++)
{
if(j==i)
continue;
l[i]*=(x-x[j])/(x[i]-x[j]);
}
}
for(i=0;i<=n;i++)
y+=l[i]*y[i];
printf("n=1,y=%lf\n",y);
}
跪求错误在哪儿,实在找不着啊,谢谢了!!! 展开
#include <stdio.h>
#define n 1
main()
{
int i,j;
float a[4]={-0.25,-0.5,-0.75,0},b[4]={0.33493750,-0.02475000,-0.07181250,1.101},x[n+1],y[n+1],l[n+1],x=-1.0/3,y=0;
for(i=0;i<=n;i++)
{
x[i]=a[i];
y[i]=b[i];
l[i]=1;
}
for(i=0;i<=n;i++)
{
for(j=0;j<=n;j++)
{
if(j==i)
continue;
l[i]*=(x-x[j])/(x[i]-x[j]);
}
}
for(i=0;i<=n;i++)
y+=l[i]*y[i];
printf("n=1,y=%lf\n",y);
}
跪求错误在哪儿,实在找不着啊,谢谢了!!! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询