设为首页 加入收藏

TOP

c/c++ 标准库 map set 大锅炖(二)
2018-10-21 14:12:32 】 浏览:72
Tags:c/c 标准 map set 大锅
;second; cout << map_it->second << endl;//2 set<int> iset{1,2,2,3,3,5}; set<int>::iterator set_it = iset.begin(); //*set_it = 10;//错误,不可以改变set的key */ //test3 遍历关联容器 /* map<string, int> cnt{{"dd",1}, {"cc",2},{"aa", 10}}; map<string, int>::const_iterator map_it = cnt.cbegin(); while(map_it != cnt.cend()){ cout << map_it->first << ":" << map_it->second << endl; ++map_it; } for(auto &s : cnt){ cout << s.first << ":" << s.second << endl; } auto it = cnt.begin(); pair<string, int> p1 = *it; */ //test4 关联容器的通用算法 multiset<string> c{"aa","aa","dd","cc"}; vector<string> v{"ee","ff"}; //copy(v.begin(),v.end(), inserter(c, c.end()));//OK //copy(v.begin(),v.end(), back_inserter(c));//NG,关联容器没有push_back //copy(c.begin(),c.end(), inserter(v, v.end()));//OK,并且c的begin到end时拍好\\ 序的 copy(c.begin(),c.end(), back_inserter(v)); for(auto &s : c){ cout << s << " "; } cout << endl; for(auto &s : v){ cout << s << " "; } cout << endl; return 0; }

github完整代码

c/c++ 学习互助QQ群:877684253

本人微信:xiaoshitou5854

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇kdTree相关原理及c++实现 下一篇C++ 保留有效小数 保留有效数字

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目