• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
FightingForWorldFinal
博客园    首页    新随笔    联系   管理    订阅  订阅

HDU2094容器使用之set

 1 #include<iostream>
 2 #include<set>
 3 #include<algorithm>
 4 #include<string>
 5 using namespace std;
 6 int main()
 7 {//freopen("C:\\Users\\Sky\\Desktop\\1.in","r",stdin);
 8     int n,i;
 9     string s1,s2;
10     set<string>a,b;
11     set<string>::iterator it;
12     while(cin>>n,n)
13     {
14          for(i=1;i<=n;i++)
15          {
16             cin>>s1>>s2;
17             a.insert(s1);
18             b.insert(s2);
19          }
20          for(it=b.begin();it!=b.end();it++)
21          {
22              if(find(a.begin(),a.end(),*it)!=a.end())
23                  a.erase(*find(a.begin(),a.end(),*it));
24          }
25 
26          if(a.size()==1)
27                 cout<<"Yes"<<endl;
28          else
29                 cout<<"No"<<endl;
30      
31   /*
32   for(it=a.begin();it!=a.end();it++)
33          cout<<*it<<endl;*/
34          a.clear();  //清空容器
35          b.clear();
36     }
37     return 0;
38 }
View Code

 

posted @ 2013-07-16 16:00  Sky-J  阅读(190)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3