结构体-heap排序
来源:互联网 发布:java getstacktrace 编辑:程序博客网 时间:2024/05/08 06:29
头文件
#include <algorithm>
make_heap(start,end,function) [start,end)
pop_heap(start,end,function) [start,end)->[start,end-1) 根->end-1
push_heap(start,end,function) [start,end-1)->[start,end)调整堆
heap_sort(start,end,function) [start,end) 堆排
// edit by colin// 20141104// usage of heap in stl#include <iostream>#include <algorithm>using namespace std;struct test{ int a; int b; int c;}tt[11];bool comp(const test &one,const test &two){ return one.c < two.c;}int main(){ for(int i=0;i<11;++i) tt[i].c = i+1; srand((unsigned)time(NULL)); random_shuffle(&tt[0],&tt[11]); for(int i=0;i<11;++i) cout<<tt[i].c<<" "; cout<<endl; make_heap(&tt[0],&tt[10],comp); for(int i=0;i<11;++i) cout<<tt[i].c<<" "; cout<<endl; //pop_heap(&tt[0],&tt[10],comp); push_heap(&tt[0],&tt[11],comp); for(int i=0;i<11;++i) cout<<tt[i].c<<" "; cout<<endl; sort_heap(&tt[0],&tt[11],comp); for(int i=0;i<11;++i) cout<<tt[i].c<<" "; cout<<endl; return 0;}
0 0
- 结构体-heap排序
- heap排序
- heap 排序
- Heap 排序
- 堆排序(Heap Sort)
- 堆排序(Heap Sort)
- 堆排序(Heap Sort)
- 堆排序 (Heap Sort)
- 堆排序(Heap Sort)
- Heap-堆排序
- (14)heap排序
- heap sort 堆排序
- 堆排序 Heap Sort
- 堆排序 Heap Sort
- 堆排序 (Heap Sort)
- 堆排序Heap sort
- 堆排序 Heap Sort
- 堆排序(Heap Sort)
- python ssh2远程登录节点并执行命令
- 宾馆自助洗衣设备的发展前景
- rpm rebuild apache2.4 on centos 6.5
- Gulp.js----比Grunt更易用的前端构建工具
- Linux Shell函数返回值 .
- 结构体-heap排序
- spring源码阅读之BeanFactory
- 机器学习资料整理
- XSLT使用实例
- Python列表序列及字典的操作
- android图片的缓存--节约内存提高程序效率
- 面向对象中多态和泛型的关系
- 绿色版的PDF格式文件转换器
- [PHP]会话小结