zoukankan      html  css  js  c++  java
  • 堆栈

    #include <stack>
    using namespace std;
    stack<元素类型[,底层容器类型]> 堆栈对象(构造实参表);
    底层容器:vector/deque(默认)/list
    push -> push_back
    pop -> pop_back
    top -> back
    size -> size
    empty -> empty
    clear -> clear

    #include <iostream>
    #include <stack>
    #include <vector>
    #include <list>
    using namespace std;
    int main (void) {
    //    stack<string, vector<string> > ss;
    //    stack<string, list<string> > ss;
    stack<string> ss;
    ss.push ("C++!");
    ss.push ("喜欢");
    ss.push ("我们");
    while (! ss.empty ()) {
    cout << ss.top () << flush;
    ss.pop ();
    }
    cout << endl;
    return 0;
    }
  • 相关阅读:
    小数化分数2
    Sum of divisors
    Subsequence
    Lowest Bit
    Specialized Four-Digit Numbers
    Hunters
    Pet
    测试你是否和LTC水平一样高
    Bank Interest
    bzoj 1295
  • 原文地址:https://www.cnblogs.com/LuckCoder/p/8668449.html
Copyright © 2011-2022 走看看