priority_queue
#include<iostream> #include<functional> #include<queue> using namespace std; struct node { friend bool operator<(node n1,node n2) { return n1.priority<n2.priority; } int priority,value; }; int main() { priority_queue<node>q; node b[5]; for(int i=0;i<5;i++) { b[i].priority=5-i; b[i].value=i; } for(int i=0;i<5;i++) q.push(b[i]); for(int i=0;i<5;i++) { cout<<q.top().priority<<'\t'<<q.top().value<<endl; q.pop(); } return 0; }