(1)曲线拟合:#includestdio.h#includemath.h#defineMAX100voidmain(){inti,j,k,m,n,N,mi;floattmp,mx;floatX[MAX][MAX],Y[MAX],x[MAX],y[MAX],a[MAX];printf(\n输入拟合多项式的次数:\n);scanf(%d,&m);printf(\n输入给定点的个数n及坐标(x,y):\n);scanf(%d,&N);printf(\n);for(i=0;iN;i++)scanf(%f,%f,&x[i],&y[i]);for(i=0;i=m;i++){for(j=i;j=m;j++){tmp=0;for(k=0;kN;k++)tmp=tmp+pow(x[k],(i+j));X[i][j]=tmp;X[j][i]=X[i][j];}}for(i=0;i=m;i++){tmp=0;for(k=0;kN;k++)tmp=tmp+y[k]*pow(x[k],i);Y[i]=tmp;}for(j=0;jm;j++){for(i=j+1,mi=j,mx=fabs(X[j][j]);i=m;i++)if(fabs(X[i][j])mx){mi=i;mx=fabs(X[i][j]);}if(jmi){tmp=Y[j];Y[j]=Y[mi];Y[mi]=tmp;for(k=j;k=m;k++){tmp=X[j][k];X[j][k]=X[mi][k];X[mi][k]=tmp;}}for(i=j+1;i=m;i++){tmp=-X[i][j]/X[j][j];Y[i]+=Y[j]*tmp;for(k=j;k=m;k++)X[i][k]+=X[j][k]*tmp;}}a[m]=Y[m]/X[m][m];for(i=m-1;i=0;i--){a[i]=Y[i];for(j=i+1;j=m;j++)a[i]-=X[i][j]*a[j];a[i]/=X[i][i];}printf(\n所求的二次多项式为:\n);printf(P(x)=%f,a[0]);for(i=1;i=m;i++)printf(+(%f)*x^%d,a[i],i);}输入拟合多项式的次数:2输入给定点的个数n及坐标(x,y):51,25,32,48,3-1,5所求的二次多项式为:P(x)=3.952280+(-0.506315)*x^1+(0.050877)*x^2Pressanykeytocontinue