#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
int main()
{
int a[]={5,1,9,4,6,2,0,3,8,7};
make_heap(a,a+10,less<int>());
cout<<"make_heap:";
copy(a,a+10,ostream_iterator<int>(cout," "));
cout<<endl;
int b[]={5,1,9,4,6,2,0,3,8,7};
vector<int> heap;
for(int i=0;i<10;i++)
{
heap.push_back(b[i]);
push_heap(heap.begin(),heap.end(),less<int>());
}
cout<<"push_heap:";
copy(heap.begin(),heap.end(),ostream_iterator<int>(cout," "));
}
make_heap 和 push_heap
最新推荐文章于 2020-11-02 02:32:00 发布