简介
show code
code
#include <set>
#include <vector>
#include <list>
#include <iostream>
#include <memory>
#include <algorithm>
using namespace std;
int main() {
vector<int> a = {1, 2, 3, 4, 8, 6};
make_heap(a.begin(), a.end());
sort_heap(a.begin(), a.end());
cout <<"
";
for(auto it:a) std::cout << it << " ";
make_heap(a.begin(), a.end());
cout <<"
";
for(auto it:a) std::cout << it << " ";
a.push_back(7);
push_heap(a.begin(), a.end());
cout <<"
";
for(auto it:a) std::cout << it << " ";
}