标签:double 直接 open lap bsp oid ++ none pre
直接上模板:
//n是方程的个数 void gauss(Matrix A,int n) { int i,j,k,r; for(int i=0; i<n; i++) { r=i; for( j=i+1; j<n; j++) if(fabs(A[j][i])>fabs(A[r][i]))r=j; if(r!=i) for(j=0; j<=n; j++)swap(A[r][j],A[i][j]); for(k=i+1; k<n; k++) { double f=A[k][i]/A[i][i]; for(j=i; j<=n; j++) A[k][j]-=f*A[i][j]; } } for(i=n-1; i>=0; i--) { for(j=i+1; j<n; j++) A[i][n]-=A[j][n]*A[i][j]; A[i][n]/=A[i][i]; } }
标签:double 直接 open lap bsp oid ++ none pre
原文地址:http://www.cnblogs.com/FriskyPuppy/p/7462694.html