首页 > 编程语言 > 详细

[c++] stack的使用

时间:2016-05-29 18:26:39      阅读:236      评论:0      收藏:0      [点我收藏+]
 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 }

[c++] stack的使用

原文:http://www.cnblogs.com/naive/p/5539911.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!