",i,x1[i]); }}}运行结果:GS迭代算法:#include<iostream.h>#include<math.h>#include<stdio.h>constintm=11;voidmain(){intchoice=1;while(choice==1){doublea[m][m],b[m],e,x[m],y[m],w,se,max;intn,i,j,N,k;cout<<"Gauss-Seidol迭代法"<<endl;?cout<<"请输入方程的个数:";cin>>n;for(i=1;i<=n;i++){cout<<"请输入第"<<i<<"个方程的各项系数:";for(j=1;j<=n;j++)cin>>a[i][j];}cout<<"请输入各个方程等号右边的常数项:\n";for(i=1;i<=n;i++){cin>>b[i];}cout<<"请输入最大迭代次数:";cin>>N;cout<<"请输入最大偏差:";cin>>e;for(i=1;i<=n;i++){x[i]=0;y[i]=x[i];}k=0;while(k!=N){k++;for(i=1;i<=n;i++){w=0;for(j=1;j<=n;j++){if(j!=i)w=w+a[i][j]*y[j];}y[i]=(b[i]-w)/double(a[i][i]);}max=fabs(x[1]-y[1]);for(i=1;i<=n;i++){se=fabs(x[i]-y[i]);if(se>max)max=se;}if(max<e){cout<<endl;for(i=1;i<=n;i++)cout<<"x"<<i<<"="<<y[i]<<endl;break;}for(i=1;i<=n;i++){x[i]=y[i];}}if(k==N)cout<<"迭代失败!!"<<endl;?choice=0;}}