[q]=t; } t=sums[k];sums[k]=sums[is];sums[is]=t; }d=MatrixA[k*index+k];?for(j=k;j<=index-1;j++) {p=k*index+j;MatrixA[p]=MatrixA[p]/d;}?sums[k]=sums[k]/d;?for(i=k+1;i<=index-1;i++) {for(j=k+1;j<=index-1;j++) { p=i*index+j; MatrixA[p]=MatrixA[p]-MatrixA[i*index+k]*MatrixA[k*index+j]; } sums[i]=sums[i]-MatrixA[i*index+k]*sums[k]; }?}d=MatrixA[(index-1)*index+index-1];?if(fabs(d)+1.0==1.0)?{?cout<<"fail"<<endl;?return(0);?}?solu[index-1]=sums[index-1]/d;//回代过程?for(i=index-2;i>=0;i--)?{?t=0.0;?for(j=i+1;j<=index-1;j++) t=t+MatrixA[i*index+j]*solu[j]; solu[i]=sums[i]-t;?}}intmain()//主函数{doublea[]=?{2,-0.5,-0.5,0,-0.5,2,0,-0.5,-0.5,0,2,-0.5,0,-0.5,-0.5,2}; doubleb[4]={0,3,3,0}; Linequequl(4); equl.setLinequ(a,b); equl.printL(); if(equl.Solve()) equl.showX(); else cout<<"Fail"<<endl; return0;}运行结果: