STL set 与 map 实例
来源:互联网 发布:越南手机网络制式 编辑:程序博客网 时间:2024/05/22 12:52
set:
//// 081_STL set.cpp// changlle//// Created by user on 12/30/15.// Copyright (c) 2015 user. All rights reserved.//#include <iostream>#include <set>using namespace std;int main () { set<int> s; s.insert(1); s.insert(3); s.insert(5); set<int>::iterator ite; ite=s.find(1); if( ite==s.end()) cout<<"not found"<<endl; else cout<<"found"<<endl; ite=s.find(2); if (ite==s.end()) cout<<"not found"<<endl; else cout<<"found"<<endl; s.erase(3); ite=s.find(3); if (ite==s.end()) cout<<"not found"<<endl; else cout<<"found"<<endl; for ( ite=s.begin();ite!=s.end();++ite) cout<<*ite<<endl; return 0;}
map:
//// 082_STL map.cpp// changlle//// Created by user on 12/30/15.// Copyright (c) 2015 user. All rights reserved.//#include <iostream>#include <map>#include <string>using namespace std;int main() { map<int, const char*> m; m.insert(make_pair(1,"one")); m.insert(make_pair(10,"ten")); m[100]="hundred"; map<int, const char*>::iterator ite; ite=m.find(1); cout<<ite->second<<endl; ite =m.find(2); if (ite==m.end()) cout<<"not found"<<endl; else cout<<ite->second<<endl; cout<<m[10]<<endl; m.erase(10); for (ite=m.begin(); ite!=m.end();ite++) cout<<ite->first<<" "<<ite->second<<endl; return 0;}
0 0
- STL set 与 map 实例
- STL中的SET与MAP
- stl中map与set
- STL之set、map基本使用实例
- stl之3 set 与map
- 【STL】map与set的使用方法
- c++中map与set容器实例
- STL <set><map>
- stl map set
- STL map&set
- STL set map容器
- 【STL】 map、set;
- STL浅析set&map
- STL中的set&&map
- stl-map/set
- c++STL(四)关联容器set与map
- C++ STL标准库的关联容器set与map
- STL 关联式容器 Set与Map的用法
- 开发旅程
- 在outlook中设置<img>大小
- Android ActionBar的基本用法
- centOS 6.5 编译安装Ambari 2.1.2
- Ping
- STL set 与 map 实例
- 数据库
- Dynamics Crm 2015 中的位置position
- Codeforces 609D Gadgets for dollars and pounds 【二分】
- 在FLASH中固定位置存入数据
- market排名
- ubuntu gcc低版本过低引起错误
- 域名解析正确性校验脚本(python多进程)
- JSP页面内嵌PDF文档