c++STL(四)关联容器set与map
来源:互联网 发布:mac怎么整理桌面图标 编辑:程序博客网 时间:2024/05/29 10:01
#include<iostream>#include<algorithm>#include<map>#include<set>#include<utility>#include<string>using namespace std;//在map中传入比较函数 struct cmp{ bool operator ()(string a, string b) { if(a.compare(1,a.size()-1,b,1,b.size()-1)<0) return false; else return true; }};int main(){ set<string> ss= {"cc","bb","aa","a","h","ww","d","v","b","aaa"}; map<string,int,cmp> a; string b; while(cin>>b) if(ss.find(b)!=ss.end()) ++a[b]; for(auto &i:a) cout<<i.first<<" "<<i.second<<endl;//第一种遍历 /*for(auto iter=a.begin();iter!=a.end();iter++) { cout<<iter->first<<" "<<iter->second; }*///第二种遍历 return 0;}
0 0
- c++STL(四)关联容器set与map
- C++STL之关联容器【map】【set】
- STL概览-关联容器set,multiset,map,multimap(四)
- C++ STL标准库的关联容器set与map
- STL 关联式容器 Set与Map的用法
- STL之关联容器(pair、map、set的使用)
- STL之关联容器(pair、map、set的使用)
- 【C/C++】关联容器pair map set
- C++:关联容器(set,multiset,map,multimap)
- C++:关联容器(pair、map、set、multiset)
- STL关联容器MAP、SET与multimap、multiset与hashmap、hashset的区别
- STL关联容器--Set
- C++学习笔记(五):关联容器--map与set
- 关联容器map set
- 关联容器 set map
- 关联容器map,set
- 关联容器set map
- STL::map关联容器
- Linux常用目录的作用
- Caffe: net.set_mode_gpu VS. caffe.set_mode_gpu
- Linux内核文件系统学习:虚拟文件系统(多图)
- RHEL7 postgreSQL安装
- 2014年880个合集Android_实例子源代码文件下载地址合集-2014
- c++STL(四)关联容器set与map
- initCompent()和构造函数(constructor)
- ceph安装时报错RuntimeError: NoSectionError
- Android应用程序资源
- c++STL(六)各种函数总结
- 画三维图像
- “2016 Esri全球开发者峰会”魅力总览
- myeclipse无法找到JPEGImageEncoder问题
- SystemClock.sleep和Thread.sleep源码分析