seqstackmain.cpp
来自「这是c++版本的数据结构」· C++ 代码 · 共 41 行
CPP
41 行
//SeqStackMain.cpp
#include <iostream> //引用输入输出流
using namespace std;
#include "SeqStack.cpp" //引入成员函数文件
void main()
{
SeqStack<int> a; //创建模板类的实例
if (a.Empty( )){
cout<<"栈空,执行入栈操作:"<<endl;
cout<<"对15和10执行入栈操作:"<<endl;
try
{
a.Push(15);
a.Push(10);
}
catch(char* wrong)
{
cout<< wrong;
}
cout<<"栈顶元素为:"<<endl; //取栈顶元素
cout<<a.GetTop( )<<endl;
cout<<"执行出栈操作:"<<endl;
cout<<a.Pop( )<<endl; //执行出栈操作
cout<<"栈顶元素为:"<<endl;
cout<<a.GetTop( )<<endl;
}
else{
cout<<"栈不空"<<endl;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?