📄 astack1.cpp
字号:
// Astack1.cpp: implementation of the Astack class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Astack1.h"
#include <iostream>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Astack::Astack()
{
toper=0;
Array[0]=0;
}
Astack::Astack(const Astack &A)
{
for(toper=1;toper<=A.toper;toper++)
{
Array[toper]=A.Array[toper];
}
toper--;
}
Astack::~Astack()
{
clean();
}
void Astack::push(char a)
{
if(toper>Max)
{
cout<<"Full!"<<endl;
}
else
{ toper++;
Array[toper]=a;
}
}
void Astack::pop()
{ int a;
if(toper!=0)
{
a=Array[toper];
toper--;
}
else
{
cout<<"棧中没有元素!"<<endl;
}
}
void Astack::print()
{
int i=toper;
if(toper==0)
{
cout<<"Empty!"<<endl;
return;
}
for(;i>0;i--)
{
cout<<Array[i]<<endl;
}
}
void Astack::clean()
{
toper=0;
Array[0]=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -