代码:
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> q; //优先队列,每次将最大值放在队首,通过push取出队首元素;若要取最小值,将入队元素变为负数即可
int a,b,c,max1,min1,min2;
int main{
cin>>a>>b>>c;
q.push(a),q.push(b),q.push(c); //入队
max1 = q.top(),q.pop(); //,取出队首元素,然后出队
min2 = q.top(),q.pop();
min1 = q.top(),q.pop();
.........
return 0;
}
标签:queue,队首,top,pop,---,push,priority From: https://www.cnblogs.com/bzlx1717/p/17427962.html