C++

#define和typedef的用法

优先队列

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<queue> // 包含最大堆与队列,已经包含了vector
using namespace std;
int main(){
priority_queue<int> hh; // 大根堆
priority_queue<int,vector<int>,greater<int>> tt; // 小根堆

hh.push(1); // 1.存入元素
bool flag = hh.empty(); // 判断是否为空
hh.top(); // 获取队首元素
hh.pop(); // 删除元素
hh.size(); // 获取元素个数
return 0;
}