码迷,mamicode.com
首页 > 其他好文 > 详细

STL 模板库中的Stack(栈)使用

时间:2014-12-07 06:27:10      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:style   io   os   使用   sp   for   strong   on   代码   

Stack 从名字中可以看得出来意思是栈,

栈的特点就是先进后出,FILO.

具体使用看下面的代码:


#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<int> sc;
for(int i = 0; i < 10l; ++i)
sc.push(i);
while( !sc.empty())
{
cout<<sc.top()<<" ";
sc.pop();
}
cout<<endl;
cin.get();
return 0;
}

STL 模板库中的Stack(栈)使用

标签:style   io   os   使用   sp   for   strong   on   代码   

原文地址:http://www.cnblogs.com/yuyanbian/p/4149065.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!