11.2.1
来源:互联网 发布:nginx 只能访问index 编辑:程序博客网 时间:2024/06/05 14:44
11.5
set中保存一个key值。同时它也value值,
map不仅有一个key值,还有一个与它相关联的value值,如果你需要另一个 ,你就需要使用map,如果不需要就使用set
11.6
@http://stackoverflow.com/questions/2302681/c-stl-list-vs-set
ListSearching (linear time).Inserting, deleting, moving (takes constant time).Elements may be ordered.Elements may be sorted.Elements may be duplicate.SetSearching (logarithmic in size).Insert and delete (logarithimic in general).Elements are un-ordered.Elements are always sorted from lower to higher.Elements are unique.
11.7
#include <iostream>#include <map>#include <string>#include <algorithm>#include <vector>using std::string;using std::vector;using std::map;using std::cin;using std::cout;using std::endl;using Families = map<string, vector<string>>;Families make_families(){ Families families; string in1,in2; cout << "姓:" << endl; cin >> in1; cout << "孩子:" << endl; while (cin >> in2) { families[in1].push_back(in2); } return families;}int main() { auto mf = make_families(); for (const auto &a : mf) { cout << "姓"<<a.first << ":\n"; for (const auto &b : a.second) { cout << b << " "; } } return 0;}
11.8
@Yue Wang Sep
#include <iostream>#include <string>#include <vector>#include <algorithm>int main(){ std::vector<std::string> exclude = { "aa", "bb", "cc", "dd", "ee", "ff" }; for (std::string word; std::cout << "Enter plz:\n", std::cin >> word; ) { auto is_excluded = std::binary_search(exclude.cbegin(), exclude.cend(), word); auto reply = is_excluded ? "excluded" : "not excluded"; std::cout << reply << std::endl; } return 0;}
使用vector需要自己去寻找单词是不是出现过,而set就不用
0 0
- 11.2.1
- 11.2.1节练习
- 数据库<11.2.1>视图
- 11.2.1 只读算法
- 11.2.1 find_first_of函数
- 算法导论 练习题 11.2-1
- 2017.11.1~11.2模拟题
- 2017.11.1~11.2考试总结
- 算法导论第十一章----11.2.1-11.2.5
- 升级Oracle Rac 11.2.0.4 到 11.2.0.4.1
- 11.2.1 源代码调试(1)
- 11.2
- 11.2
- 11.2
- 11.2
- 11.2
- 11.2
- 11.2
- Arithmetic problem | The Triangle
- 【Python】生成图片验证码
- 年味并没有失效,只是你我早已过了那个时间段
- Reverse Linked List
- Windows 容器快速入门
- 11.2.1
- Android 全局广播的使用
- mysql字符串函数学习笔记
- jsp&servlet基础知识点
- 108. Convert Sorted Array to Binary Search Tree 有序数组转换为平衡二叉搜索树
- VS2013 下 使用Windows Caffe开发之配置属性文件
- Algorithm理解用例:分治法
- LeetCode-未解决题目
- 使用faster rcnn训练自己的数据-制作数据集