⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exp20_3.cpp

📁 高等教育出版社出版的C++程序设计同步实验范例 希望对用这本教材得同学有点帮助
💻 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 + -