第五章 总结
来源:互联网 发布:qq for linux 2017 编辑:程序博客网 时间:2024/06/14 00:49
//检索int main() {int a[] = { 10, 20, 30, 40 };auto p1 = find(a, a + 4, 10);auto p2 = find(a, a + 4, 0);auto p3 = lower_bound(a, a + 4, 15);//return >= valauto p4 = upper_bound(a, a + 4, 15);//return > valcout << p1 - a << endl;cout << p2 - a << endl;cout << p3 - a << endl;cout << p4 - a << endl;return 0;}//集合相关函数#include <iterator>#define ALL(x) x.begin(), x.end()#define INS(x) inserter(x, x.begin())int main() {vector<int> s1({ 1, 2, 3, 4 });vector<int> s2({ 2, 3, 4, 5 });vector<int> su, si, sd, ss;set_union(ALL(s1), ALL(s2), INS(su));set_intersection(ALL(s1), ALL(s2), INS(si));//the elements that are present in the first set, but not in the second one. set_difference(ALL(s1), ALL(s2), INS(sd));set_symmetric_difference(ALL(s1), ALL(s2), INS(ss));for (auto i : su) cout << i << ' '; cout << endl;for (auto i : si) cout << i << ' '; cout << endl;for (auto i : sd) cout << i << ' '; cout << endl;for (auto i : ss) cout << i << ' '; cout << endl;return 0;}//栈,队列,优先队列//stack: empty, size, top, push, pop, emplace, swap;//queue: empty, size, front, back, push, pop, emplace, swap;//priority_queue: empty, size, top, push, pop, emplace, swap;//assert的应用及随机数的生成#include <cstdlib>#include <ctime>#include <cassert>void fill_random_int(vector<int> &v, int cnt) {v.clear();for (int i = 0; i < cnt; ++i) v.push_back(rand());}void test_sort(vector<int> &v) {sort(v.begin(), v.end());for (int i = 0; i < v.size() - 1; i++)assert(v[i] <= v[i + 1]);}int main() {srand(time(NULL));vector<int> v;fill_random_int(v, 100000);test_sort(v);return 0;}
阅读全文
0 0
- 第五章 中央处理器 总结
- 第五章 数组总结
- 第五章总结
- 第五章知识点总结
- 总结:第一章~第五章
- 第五章 总结
- Java总结第五章
- 算法导论第五章总结
- 第五六章练习总结
- 第五章(笔记总结)
- 第五章总结(上)
- 第五章总结(下)
- C++ template第五章总结
- 数据结构:第五章知识总结
- 数据库第五章理论总结
- 矩阵第五章复习总结
- 软件工程第五章知识点总结
- Hibernate第五章知识点总结——第五章--事务管理
- Python,dict数据类型
- PHP Hash比较存在缺陷,影响大量Web网站登录认证、忘记密码等关键业务
- base64之前端加密后端解密
- 软件质量的定义
- 解决微信小程序中Date.parse()获取时间戳IOS不兼容的问题(IOS为NaN的问题)
- 第五章 总结
- 一种WPF下的界面生成框架
- JAVA设计模式之原型模式
- Android Instant App
- 如何打开高清语音VOLTE
- TCP/IP协议族名称和国际网络组织名称的缩写和全称
- 在ubuntu上遇到的一个错误。记录一下。
- vue项目构建步骤
- 《Advanced Bash-scripting Guide》学习(十二):占位符":"及其他