优先队列的初步入门

2019.2.27日学习心得

优先队列的使用

#include<iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    priority_queue<double>bb;
    bb.push(3.2);
    bb.push(9.8);
    bb.push(9.8);
    bb.push(5.4);
    while (!bb.empty())
    {
        cout << bb.top() << " ";//从大到小输出
        bb.pop;            
    }
    return 0;
}//输出9.8,9.8,5.4,3.2

poriority_queue<double, vector<double>, greater<double>aa;
//按greater方式排序;输出3.2,5.4,9.8,9.8
原文地址:https://www.cnblogs.com/fengzhongzhuifeng/p/10446292.html