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

  • 相关阅读:
    keras后端设置【转载】
    NN中的激活函数【转载】
    关于范数【转载】
    常用范数公式【转载】
    Tf中的SGDOptimizer学习【转载】
    亲和串 kmp
    kmp基础 ekmp
    Number Sequence kmp
    P1052 过河 线性dp
    P1074 靶形数独 dfs回溯法
  • 原文地址:https://www.cnblogs.com/xin-le/p/4111803.html
Copyright © 2011-2022 走看看