STL优先级队列菜鸟有问题。
#include <iostream>#include <queue>#include <deque>#include <vector>#include <functional>using namespace std;//using priority_queue with deque//哪里体现了是用deque做的?//use of function greater sorts the items in ascending ordertypedef deque<int> INTDQU;typedef priority_queue<int> INTPRQUE;//using priority_queue with vector;//哪里体现了是用deque做的?//use of function less sorts the items in ascending ordertypedef vector<char> CHVECTOR;typedef priority_queue<char> CHPRQUE;void main(void){ int size_q; INTPRQUE q; CHPRQUE p; //Insert items in the priority_queue(uses deque) q.push(42); q.push(100); q.push(49); q.push(201); size_q=q.size(); cout<<"size of q is : "<<size_q<<endl; while(!q.empty()) { cout<<q.top()<<" "; q.pop(); } cout<<endl; //Insert items in the priority_queue(uses vector) p.push('c'); p.push('a'); p.push('d'); p.push('m'); p.push('h'); cout<<p.top()<<endl; while(!p.empty()) { cout<<p.top()<<" "; p.pop(); } cout<<endl;}