hdoj 1325这样写错在那里? http://acm.hdu.edu.cn/showproblem.php?pid=1325
#include<iostream>#include<string.h>#include<stdio.h>#include<stdlib.h>#include<set>u...
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<set>
using namespace std;
#pragma warning(disable:4786)
set<int>s;
int main()
{
int x,y,cnt=0;
while(scanf("%d%d",&x,&y))
{
if(x<0||y<0) break;
int k=0,t=1;
s.clear();
if(s.find(x)==s.end()) k++,s.insert(x);
if(s.find(y)==s.end()) k++,s.insert(y);
while(scanf("%d%d",&x,&y))
{
if(x==0||y==0) break;
if(s.find(x)==s.end()) k++,s.insert(x);
if(s.find(y)==s.end()) k++,s.insert(y);
t++;
}
cnt++;
//printf("%d %d\n",k,t);
if(k==t+1) printf("Case %d is a tree.\n",cnt);
else printf("Case %d is not a tree.\n",cnt);
}
return 0;
} 展开
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<set>
using namespace std;
#pragma warning(disable:4786)
set<int>s;
int main()
{
int x,y,cnt=0;
while(scanf("%d%d",&x,&y))
{
if(x<0||y<0) break;
int k=0,t=1;
s.clear();
if(s.find(x)==s.end()) k++,s.insert(x);
if(s.find(y)==s.end()) k++,s.insert(y);
while(scanf("%d%d",&x,&y))
{
if(x==0||y==0) break;
if(s.find(x)==s.end()) k++,s.insert(x);
if(s.find(y)==s.end()) k++,s.insert(y);
t++;
}
cnt++;
//printf("%d %d\n",k,t);
if(k==t+1) printf("Case %d is a tree.\n",cnt);
else printf("Case %d is not a tree.\n",cnt);
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询