📄 main.cpp
字号:
#include"iostream.h"
#include<cstdlib>
#include"stack.h"
void main()//主函数用来进行测试
{
char ch;
stack<char> s;//建立字符型堆栈s
s.push('A');//将字符A压入堆栈
s.push('B');//将字符B压入堆栈
s.push('C');//将字符C压入堆栈
cout<<"Now the value of top is "<<s.top<<" after push three elements into the stack."<<endl;
s.pop();//弹出栈顶的元素
ch=s.topandpop();//弹出栈顶的元素并且返回其值给ch
cout<<"Now the value of top is "<<s.top<<" after two pops."<<endl;
cout<<"Now the value of ch is:"<<endl<<ch<<endl;
cout<<"Now the top element of stack is:"<<endl<<s.getTop()<<endl;
s.pop();//继续弹出栈顶元素
s.pop();//此时程序会报错,显示堆栈已空
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -