/*
============================================================================
Name : stack_lib.cpp
Author : ntsk13 beijiwei@qq.com
Version :
Copyright : GPL
Description : stack library study, complement by C++
Date : 2015.06.18
============================================================================
*/
#include <iostream>
#include <stack>
using namespace std;
int main(void) {
stack<int> st;
int len=0;
st.push(4);
st.push(3);
st.push(2);
st.push(1);
st.push(0);
cout<<"size is "<<st.size()<<endl;
cout<<"top elem is "<<st.top()<<endl;
len=st.size();
for(int i=0;i<len;i++)
{
cout<<"After pop, The "<<i<<"th top elem is "<< st.top()<<endl;
st.pop();
}
return 0;
}
简单数据结构之栈(C++模板库实现)
最新推荐文章于 2023-07-30 00:02:34 发布