/*
STL stack
堆栈:LIFO后进先出
自适应容器(容器适配器)
栈适配器 STL stack
stack<int,deque<int>> s; //默认堆栈
stack<int,vector<int>> s;
stack<int,list<int>> s;
s.empty() 堆栈清空
s.size() 堆栈容量
s.pop() 删除栈顶数据 不返回值
s.top() 返回栈顶数据
s.push(item) 从栈顶压入数据
*/
#include<iostream>
#include<stack>
using namespace std;
int main(){
stack<int,deque<int>> s;
s.push(5);
s.push(4);
s.push(3);
s.push(2);
s.push(1);
while(s.empty()==false) //s.size()!=0
{ int x=s.top();
cout<<x<<endl;
s.pop();
} //通过删除栈顶数据 以及通过输出栈顶数据 把整个堆栈的数据全部输出来
}
STL stack
堆栈:LIFO后进先出
自适应容器(容器适配器)
栈适配器 STL stack
stack<int,deque<int>> s; //默认堆栈
stack<int,vector<int>> s;
stack<int,list<int>> s;
s.empty() 堆栈清空
s.size() 堆栈容量
s.pop() 删除栈顶数据 不返回值
s.top() 返回栈顶数据
s.push(item) 从栈顶压入数据
*/
#include<iostream>
#include<stack>
using namespace std;
int main(){
stack<int,deque<int>> s;
s.push(5);
s.push(4);
s.push(3);
s.push(2);
s.push(1);
while(s.empty()==false) //s.size()!=0
{ int x=s.top();
cout<<x<<endl;
s.pop();
} //通过删除栈顶数据 以及通过输出栈顶数据 把整个堆栈的数据全部输出来
}