priority_queue
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int main(){
// priority_queue<int> q;
// priority_queue<int, vector<int>, greater<int>> q;
auto cmp=[](int a, int b){
return a<b;
};
priority_queue<int, vector<int>, decltype(cmp)>q(cmp);
vector<int> v={8, 1, 6, 4, 0, 7, 2, 9};
for(int x: v) q.push(x);
while(!q.empty()){
cout<<q.top()<<" ";
q.pop();
}
cout<<endl;
return 0;
}
Comments
Post a Comment