priority_queue 用法

#include <iostream>
#include <cstdlib>
#include <queue>
 
using namespace std;
 
struct Node
{
    int x, y;

   bool operator<(const Node& b) const { return x > b.x; } }; int main() { priority_queue<Node> q; for( int i= 0; i< 10; ++i ) { Node n; n.x = rand(); n.y = rand(); q.push(n); } while( !q.empty() ) { cout << q.top().x << ' ' << q.top().y << endl; q.pop(); } return 0; }
posted @ 2012-04-24 13:25  flowskyac  阅读(133)  评论(0编辑  收藏  举报