Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341670
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:05:44

 #include
 #include
 #include
 #include
 #include
 using namespace std;
 int main(void)
 {
   // Make a priority queue of int using a vector container
   priority_queue, less > pq;

   // Push a couple of values
   pq.push(1);
   pq.push(2);
   // Pop a couple of values and examine the ends
   cout << pq.top() << endl;
   pq.pop();
   cout << pq.top() << endl;

   pq.pop();
   // Make a priority queue of strings using
   // a deque container
   priority_queue, less >
      pqs;
   // Push on a few strings then pop them back off
   int i;
   for (i = 0; i < 10; i++)
   {
     pqs.push(string(i+1,'a'));
     cout << pqs.top() << endl;
   }
   for (i = 0; i < 10; i++)
   {
     cout << pqs.top() << endl;
     pqs.pop();
   }
   // Make a priority queue of strings using a deque    

   // container, and greater as the compare operation
   priority_queue, greater >
      pgqs;
   // Push on a few strings then pop them back off
   for (i = 0; i < 10; i++)
   {
     pgqs.push(string(i+1,'a'));
     cout << pgqs.top() << endl;
   }
   for (i = 0; i < 10; i++)
   {
     cout << pgqs.top() << endl;
     pgqs.pop();
   }
   return 0;
 }

--------------------next---------------------

阅读(1005) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~