zoukankan      html  css  js  c++  java
  • 第19章 queue队列容器

    /*
    
      第19章 queue队列容器
       19.1 queue技术原理
       19.2 queue应用基础
       19.3 本章小结
    */
    
    
    
    //  第19章 queue队列容器
    //   19.1 queue技术原理
    //   19.2 queue应用基础 -------------------------------------------------------------------------------------------
    
    
    //273
    #include <queue>
    #include <iostream>
    int main(void)
    {
      using namespace std;
      //创建queue对象
      queue < int > q;
      //元素入队
      q.push(3);
      q.push(19);
      q.push(29);
      q.push(26);
      q.push(33);
      //元素出队
      while(!q.empty())
      {
        cout << q.front() << endl; //打印队首元素(取队首)
        q.pop(); //删除队首元素
      }
      return 0;
    }
    
    
    //274
    #include <queue>
    #include <list>
    #include <iostream>
    #define QUEUE_SIZE 50
    int main(void)
    {
      using namespace std;
      //用双向链表做queue队列的底层容器
      queue < int, list < int >  > q;
      if(q.size() < QUEUE_SIZE)
        q.push(51);
      if(q.size() < QUEUE_SIZE)
        q.push(36);
      if(q.size() < QUEUE_SIZE)
        q.push(28);
      //元素出队
      while(!q.empty())
      {
        cout << q.front() << endl; //打印51 36 28
        q.pop(); //出队
      }
      return 0;
    }
    
    
    //   19.3 本章小结

    TOP

  • 相关阅读:
    linux下base命令
    lldpd-0.7.7代码解读(send_pdu部分)
    openwrt 包makefile
    字符
    AC_CONFIG_HEADER
    大小端
    查看使用了那种shell
    debia下安装libjpeg
    工作流模式 (zhuan)
    1.2.1 工作流管理系统参考模型 (zhuan)
  • 原文地址:https://www.cnblogs.com/xin-le/p/4111803.html
Copyright © 2011-2022 走看看