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

Re:200,留念,挫代码,我也贴

Posted by pirates at 2012-07-23 00:33:10 on Problem 1308
In Reply To:200,留念,挫代码,我也贴 Posted by:2007210566 at 2009-08-15 04:49:21
> #include<iostream>
> using namespace std;
> int main()
> {	int tree[15],treef[15],a,b,c,node,cas=1,tag;	
> 	while(cin>>a>>b&&(a!=-1||b!=-1))
> 	{
> 		if(a==0&&b==0)
> 			cout<<"Case "<<cas<<" is a tree."<<endl;
> 		else
> 		{	node=tag=1;
> 			if(a==b)
> 			tag=0;			
> 			memset(tree,0,15*sizeof(int));
> 			memset(treef,0,15*sizeof(int));
> 			tree[b]++;
> 			treef[a]++;
> 			treef[b]++;
> 			while(cin>>a>>b&&(a||b))
> 			{tree[b]++;treef[a]++;treef[b]++;node++;
> 			if(a==b)
> 			tag=0;}
> 			b=c=0;
> 			for(a=0;a<15;a++)
> 			{if(tree[a]>=2)
> 					tag=0;
> 			b+=tree[a];
> 			if(treef[a]!=0&&tree[a]==0)
> 			c++;}
> 				if(b!=node)
> 					tag=0;
> 				if(c!=1)
> 					tag=0;
> 			if(tag)
> 				cout<<"Case "<<cas<<" is a tree."<<endl;
> 			else
> 				cout<<"Case "<<cas<<" is not a tree."<<endl;
> 		}
> 		cas++;
> 	}
> 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