Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么runtime error啊??高消写的,为什么RE啊,高手帮帮忙啊!! #include<iostream.h> const int dim=20; //int xs[dim][dim]; int m[dim][dim+1]; void guass()//,double b[dim])//guass消元,结果返回 m[i][dim]中 { int i,j,k=0; int xb; while(k<dim) { //////选主元 for(xb=k;xb<dim&&m[k][xb]==0;xb++); if(xb!=k) { int tmp; for(i=k;i<=dim;i++) { tmp=m[k][i]; m[k][i]=m[xb][i]; m[xb][i]=tmp; } } ////消元 for(i=k+1;i<dim;i++) { if(m[i][k]==0)continue; for(j=k;j<=dim;j++) m[i][j]^=m[k][j]; } k++; } /////回代 for (i = dim - 1; i > 0; -- i) { if (m[i][i]==0) continue; //跳过自由变元,相当于自由变元置0 for (j = i - 1; j >= 0; -- j) { if(m[j][i]==1) { m[j][dim]^=m[i][dim]; m[j][i]=0; } } } int sum=0; for(i=0;i<dim;i++) { sum+=m[i][dim]; // printf("%d",m[i][dim]); // if(i%L!=L-1)printf(" "); // else printf("\n"); } cout<<sum<<endl; } void set() { int i; for(i=1;i<dim-1;i++) { m[i][i+1]=1; m[i][i]=1; m[i][i-1]=1; } m[0][0]=m[0][1]=m[dim-1][dim-2]=m[dim-1][dim-1]=0; } int main() { //while(cin>>m[0][dim]) // { int i; for(i=0;i<20;i++) cin>>m[i][dim]; set(); guass(); // } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator