logo资料库

分段三次hermite插值.doc

第1页 / 共2页
第2页 / 共2页
资料共2页,全文预览结束
#define N 10 #include void main() { int i,n,t=1; float x[N],y[N],yy[N],X,Y; float Hermite(int n,float x[N],float y[N],float yy[N],float X); while(t) { printf("please input n(this number must between 1-%d):",N); scanf("%d",&n); if(n<1||n>N)printf("Erroe!please input n again!\n"); else t=0; } for(i=0;i<=n;i++) { printf("please input x[%d]:",i); scanf("%f",&x[i]); printf("please input y[%d]:",i); scanf("%f",&y[i]); printf("please input y'[%d]:",i); scanf("%f",&yy[i]); } printf("please input x:"); scanf("%f",&X); Y=Hermite(n,x,y,yy,X); printf("this result is:%f\n",Y); } float Hermite(int n,float x[N],float y[N],float yy[N],float X) { int i,j; float p[N],q[N],h[N],z; for(i=0;i<=n;i++) if(X
z=p[j-1]*y[j-1]+p[j]*y[j]+q[j-1]*yy[j-1]+q[j]*yy[j]; return(z); } 2
分享到:
收藏