zoukankan      html  css  js  c++  java
  • [c++] stack的使用

     1 #include<iostream>
     2 #include<stack>
     3 #include<deque>
     4 using namespace std;
     5 
     6 
     7 int main()
     8 {
     9     stack<int> first;
    10     cout << "size of first: " << first.size() << endl;
    11 
    12     for (int i=0; i<6; i++)
    13         first.push(i);
    14     cout << "size of first: " << first.size() << endl;
    15      
    16     while( !first.empty() )
    17     {
    18         cout<<first.top()<<' ';
    19         first.pop();
    20     }
    21     cout<<endl;
    22 
    23     deque<int> deq(10,0);
    24     stack<int> second( deq );
    25     cout << "size of second: " << second.size() << endl;
    26     while( !second.empty() )
    27     {
    28         cout<<second.top()<<' ';
    29         second.pop();
    30     }
    31     cout<<endl;
    32 
    33     return 0;
    34 }
  • 相关阅读:
    SQLServer 可疑
    String与Long互转
    洛谷 P5644
    洛谷 P3783
    洛谷 P4663
    洛谷 P3438
    Atcoder Grand Contest 054 题解
    迭代器失效问题
    Solution -「CF 232E」Quick Tortoise
    Solution -「NOI 2020」「洛谷 P6776」超现实树
  • 原文地址:https://www.cnblogs.com/naive/p/5539911.html
Copyright © 2011-2022 走看看