STL算法 ---------- Heap算法
来源:互联网 发布:轮播图原生js代码 编辑:程序博客网 时间:2024/05/17 09:20
---- 堆排序算法( heapsort )
2. make_heap()
2. push_heap()
3. pop_heap
4. sort_heap()
#include <iostream>#include <algorithm>#include <vector>using namespace std;template<typename T>void Print(const T& t){for(typename T::const_iterator itr=t.begin(); itr!=t.end(); ++itr){cout<<*itr<<' ';}cout<<endl;}int main( int argc, char** argv ){vector<int> vec;for(int i=3; i<=7; ++i){vec.push_back(i);}for(int i=5; i<=9; ++i){vec.push_back(i);}for(int i=1; i<=4; ++i){vec.push_back(i);}Print(vec);make_heap(vec.begin(), vec.end());Print(vec);pop_heap(vec.begin(), vec.end());vec.pop_back();Print(vec);vec.push_back(17);push_heap(vec.begin(), vec.end());Print(vec);sort_heap(vec.begin(), vec.end());Print(vec);return 0;}
0 0
- STL算法 ---------- Heap算法
- STL中的heap算法
- STL算法之heap
- C++ STL 算法:Heap算法
- 手写堆heap(STL的heap算法)
- STL算法(Algorithms):堆(heap)
- STL——Heap算法
- STL中heap算法(堆算法)
- STL算法之heap算法,已排序区间算法
- SGI-STL学习笔记之heap算法
- C++ STL——heap相关算法
- STL之heap相关操作算法
- heap算法
- 【STL】Heap算法——push_heap、pop_heap、sort_heap、make_heap
- Heap算法实现
- heap sort算法实现
- heap算法,binary_search
- c++中的Heap算法
- Unity异步加载场景loading条 复制代码
- Codeforces Round #295 (Div. 2) C. DNA Alignment(数学)
- Linux芯片级移植与底层驱动(基于3.7.4内核)
- 维棠播放器
- CDN初探
- STL算法 ---------- Heap算法
- iOS 不使用UINavigationController实现Push动画
- GCD多线程
- HDU 1028 Ignatius and the Princess III
- 编写一个函数,将一个数字字符串转换成这个字符串对应的数字(包括正浮点数、负浮点数)
- Ubuntu 下安装 vim 时出现无法安装的问题
- 云计算的原动力
- 容器第四课,JDK源代码分析,自己实现LinkedList,双向链表的概念_节点定义
- 维棠播放器