编程实现拉格朗日(lagrange)插值法(C语言)程序如下:#include #include #include float lagrange(float *x,float *y,float xx,int n) /*拉格朗日插值算法*/ int i,j; float *a,yy=0.0; /*a作为临时变量,记录拉格朗日插值多项式*/ a=(float *)malloc(n*sizeof(float); for(i=0;i=n-1;i+) ai=yi; for(j=0;j=20) printf(Error!The value of n must in (0,20).); getch();return 1; if(n=0) printf(Error! The value of n must in (0,20).); getch(); return 1; for(i=0;i=n-1;i+) printf(x%d:,i); scanf(%f,&xi); printf(n); for(i=0;i=n-1;i+) printf(y%d:,i);scanf(%f,&yi); printf(n); printf(Input xx:); scanf(%f,&xx); yy=lagrange(x,y,xx,n); printf(x=%f,y=%fn,xx,yy); getch();