美文网首页
c++ stack

c++ stack

作者: HenryTien | 来源:发表于2017-04-15 20:22 被阅读22次

    std::stack::stack

    #include <iostream>       // std::cout
    #include <stack>          // std::stack
    #include <vector>         // std::vector
    #include <deque>          // std::deque
    using namespace std;
    
    int main()
    {
        std::deque<int> mydeque(3,200); // deque with 3 elements
        std::vector<int> myvector(2,200); //vector with 2 elements
        std::stack<int> first;          //empty stack
        std::stack<int> seconde(mydeque);//stack initialized to copy of deque
    
        std::stack<int,std::vector<int> > third; //empty stack use empty vector
        std::stack<int,std::vector<int> > fourth(myvector);//stack initialized using vector
    
        std::cout<<"size of first:"<<first.size()<<"\n";
        std::cout<<"size of second:"<<seconde.size()<<"\n";
        std::cout<<"size of third:"<<third.size()<<"\n";
        std::cout<<"size of fourth:"<<fourth.size()<<"\n";
        cout << "Hello world!" << endl;
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:c++ stack

          本文链接:https://www.haomeiwen.com/subject/cdloattx.html