用C语言实现雅可比迭代法,源程序代码如下:#includestdlib.h#includestdio.h#includeconio.h#includestring.h#includemath.h#defineN100floatTable(intn,floata[N][N],floatb[N]){inti,j;floatc[N][N];printf(PleaseinputthematrixAbyrow!\n);for(i=0;in;i++){printf(Row%d:,i+1);for(j=0;jn;j++)scanf(%f,&a[i][j]);}printf(Pleaseinputthevectorb:);for(i=0;in;i++)scanf(%f,&b[i]);for(i=0;in;i++)for(j=0;jn;j++){if(i==j){c[i][j]=0;continue;}c[i][j]=-a[i][j]/a[i][i];}printf(\nThematrixAandvectorb:\n);for(i=0;in;i++){for(j=0;jn;j++)printf(%10.5f,a[i][j]);printf(%10.5f,b[i]);printf(\n);}printf(\nTheJacobiiterativescheme:\n);for(i=0;in;i++){for(j=0;jn;j++)printf(%10.5f,c[i][j]);printf(%10.5f,b[i]/a[i][i]);printf(\n);}}floatinit_vec(intn,floatx[N]){inti;printf(Pleaseinputtheinitialiterationvectorx:);for(i=0;in;i++)scanf(%f,&x[i]);printf(\nTheinitialiterationvectorx:\n);for(i=0;in;i++)printf(%10.5f,x[i]);printf(\n);}floatjacobi(intn,floata[N][N],floatb[N],floatx[N]){inti,j,k;floattmp,x2[N];for(k=0;;k++){for(i=0;in;i++)x2[i]=x[i];for(i=0;in;i++){tmp=0.0;for(j=0;jn;j++){if(j==i)continue;tmp+=a[i][j]*x2[j];}x[i]=(b[i]-tmp)/a[i][i];}for(i=0,j=0;in;i++)if(fabs(x2[i]-x[i])0.00001)j++;if(j==n){printf(\nThisJacobiiterativeschemeisconvergent!\n);printf(Numberofiterations:%d,k+1);break;}if(k==499){printf(\nThisJacobiiterativeschememaybenotconvergent!);break;}}printf(\nTheresults:\n);for(i=0;in;i++)printf(%12.7f,x[i]);}intmain(){intn;floatx[N],a[N][N],b[N];printf(Inputn:);scanf(%d,&n);Table(n,a,b);init_vec(n,x);jacobi(n,a,b,x);getch();}