特性
函数
示例
1 #include <iostream> 2 #include <stack> 3 using namespace std; 4 5 int main(){ 6 stack<int> s; 7 for(int i = 0 ; i < 10 ; i ++ ) 8 s.push(i); 9 cout<<"栈s中的元素个数为:"<<s.size()<<endl; 10 11 while(!s.empty()){ 12 cout<<" "<<s.top(); 13 s.pop(); 14 } 15 cout<<endl; 16 17 if(s.empty()){ 18 cout<<"栈s为空"<<endl; 19 } 20 21 return 0; 22 }
参考
C++中stack、queue、vector的用法详解
https://www.jb51.net/article/122462.htm
原文:https://www.cnblogs.com/cxc1357/p/12269922.html