堆排序 使用 algorithm

简介

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 << " ";

}
上一篇:堆排序演示


下一篇:freeRTOS系列教程之【第二章】内存管理