| ||||||||||
| 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 | |||||||||
哪位兄弟帮我看一下啊!怎么总是 WA啊#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator