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

哪位兄弟帮我看一下啊!怎么总是 WA啊

Posted by yangjie at 2006-03-13 22:16:09 on Problem 1308
#include <iostream>
using namespace std;

int main()
{
    int check[1000][2];
	int countX(0),countY(0);
	int pointX,pointY,number(0);

	cin >> pointX >> pointY;
	while( pointX != -1 || pointY != -1)
	{
		int judge(0);
     	while( pointX != 0 || pointY != 0)
		{

          check[countX++][0] = pointX;
	      check[countY++][1] = pointY;
	      cin >> pointX >> pointY;

		}

     	for(int i = 0 ; i < countX ; ++i)
		{
		   for(int j = 0 ; j < countX ; ++j)
		   {
			  if( (check[i][1] == check[j][1] && check[i][0] != check[j][0])|| (check[i][1] == check[j][0]&&check[i][0] == check[j][1]) ||(check[i][0] == check[i][1]) )
			  {
					judge = 1;
					break;
			  }
			  if(i != j && check[i][0] == check[j][0] && check[i][1]==check[j][1])
			  {
			     judge = 1;
				 break;
			  }
		   }

			  if(judge)break;
		}
		if(judge)
			cout << "Case "<< ++number <<" is not a tree."<<endl;
		else 
		   cout << "Case " << ++number << " is a tree."<<endl;
     	cin >> pointX >> pointY;
		countX = 0;
		countY = 0;
	}
	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