Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么runtime error啊??

Posted by y07yangruilong at 2007-11-08 14:55:24 on Problem 3185
高消写的,为什么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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator