📄 exp20_3.cpp
字号:
//stack适配器。首先看演示程序。
#include <iostream>
#include <stack>
int main()
{
using namespace std;
stack<int >s1,s2; // 构造整数栈
s1.push(10); // 整数压栈
s1.push(20);
s1.push(30);
stack<int >::size_type i; // 用于存储栈的大小
i = s1.size();
cout<<"The Stack length is"<<i<<"."<<endl;
i = s1.top(); // 取栈顶元素
cout<<"The element at the top of the stack is"<<i<<"."<<endl;
s1.pop(); // 出栈
i = s1.size();
cout<<"After a pop,the Stack length is"<<i<<"."<<endl;
i = s1.top();
cout<<"The element at the top of the stack is"<<i<<"."<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -