zoukankan      html  css  js  c++  java
  • STL之stack(栈)

    栈(statck)这种数据结构在计算机中是相当出名的。栈中的数据是先进后出的(First In Last Out, FILO)。栈只有一个出口,允许新增元素(只能在栈顶上增加)、移出元素(只能移出栈顶元素)、取得栈顶元素等操作。 在STL中栈一共就5个常用操作函数(top()、push()、pop()、 size()、empty())
    #include
    #include
    #include
    using namespace std ;
    typedef stack Q ;
    int main()  {
        Q q ;
        for(int i = 0 ; i < 10 ; i++)
            q.push(i) ;
        while(!q.empty())   {
            cout << q.top() << " " ;
            q.pop() ;
        }
        cout << endl ;
        return 0 ;
    }
    
  • 相关阅读:
    luogu 1593
    luogu 1369
    hdu 1796
    bzoj 3398
    luogu 4587
    luogu 2152
    bzoj 3629
    bzoj 1507: [NOI2003]Editor
    bzoj 1503: [NOI2004]郁闷的出纳员
    bzoj 1497: [NOI2006]最大获利
  • 原文地址:https://www.cnblogs.com/NYNU-ACM/p/4236860.html
Copyright © 2011-2022 走看看