stack 即 栈, 遵循原则 后入先出 LIFO
0 准备
#include<stack>
1 initialize & assignment
stack<int> stk;
2. operator
2.1 add
stk.push(66);
2.2 delete
stk.pop() //弹出最上面的元素
2.3 query
stk.empty();
stk.size();
stk.top();
2.4 change
stack<int> stk;
stk.push(3);
stk.push(9);
stack<int> hedq;
hedq.push(66);
hedq.push(88);
hedq.push(999);
stk.swap(hedq);
while(!stk.empty()){
cout<< stk.top()<<endl;
stk.pop();
}
3. 常见用法