C++ STL 堆的相关操作
来源:互联网 发布:html屏蔽js代码 编辑:程序博客网 时间:2024/05/14 18:10
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <list>
#include <set>
#include <cstdlib>
#include <functional>
#include <numeric>
using namespace std;
template<typename T>
void printVector(vector<T> v)
{
vector<T>::iterator it;
for(it=v.begin();it!=v.end();++it) //使用迭代器输出
cout<<*it<<" ";
cout<<endl;
}
//堆的相关操作
int main()
{
int A[]={1,4,2,6,5,7,9};
const int N=sizeof(A)/sizeof(int);
make_heap(A,A+N);
copy(A,A+N,ostream_iterator<int>(cout," "));
cout<<endl;
// sort_heap(A,A+N);
// copy(A,A+N,ostream_iterator<int>(cout," "));
// cout<<endl;
int n=N;
while(n>1)
{
copy(A,A+N,ostream_iterator<int>(cout," "));
cout<<endl;
pop_heap(A,A+n);
--n;
}
copy(A,A+N,ostream_iterator<int>(cout," "));
cout<<endl;
// pop_heap(A,A+N); //删除堆内最大元素
// copy(A,A+N-1,ostream_iterator<int>(cout," "));
// cout<<endl;
// cout<<A[N-1]<<endl;
return 0;
}
- C++ STL 堆的相关操作
- STL的堆操作
- STL的堆操作
- 堆的相关操作
- STL里面的堆操作
- 堆相关的一些操作
- STL-容器的相关操作
- c++STL排序及相关操作
- STL 堆操作
- STL 堆操作 .
- stl中的堆操作
- STL 堆操作
- STL之堆操作
- STL中的堆操作
- C++STL之堆
- STL中队列的相关操作
- 串的堆分配存储表示以及相关操作 C语言版
- 最大堆相关操作
- CENTOS5更改開機選單秒數
- 华为软件命名规范
- 5. 输出为PDF文档
- perl value排序
- 绿色分区软件PM
- C++ STL 堆的相关操作
- OTGHNP_EventNotify
- 三星I5800联系人丢失问题
- assert()用法
- 玩转照片EXIF信息的利刃:jhead命令详解 依据EXIF照片自动旋转
- java 域服务器 验证
- 从现代操作系统中学到的东西--批处理、多道程序设计、分时系统
- 双机主备DNS设置
- windows启动的过程