简介

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 <<"\n";
    for(auto it:a) std::cout << it << " ";
    make_heap(a.begin(), a.end());
    cout <<"\n";
    for(auto it:a) std::cout << it << " ";
    a.push_back(7);
    push_heap(a.begin(), a.end());
    cout <<"\n";
    for(auto it:a) std::cout << it << " ";

}
posted on 2021-07-18 09:22  HDU李少帅  阅读(40)  评论(0)    收藏  举报