stack.cpp
来自「关于栈的操作的小程序」· C++ 代码 · 共 57 行
CPP
57 行
// Stack.cpp: implementation of the CStack class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CStackOperation.h"
#include "Stack.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CStack::CStack()
{
S.top = -1;
}
CStack::~CStack()
{
}
void CStack::Push(char x)
{
if(S.top==Maxsize-1)
{
AfxMessageBox("栈溢出!");
}
S.top++;
S.elements[S.top] = x;
}
char CStack::Pop()
{
if(S.top==-1)
{
AfxMessageBox("栈空,括号不匹配!");
}
S.top--;
return S.elements[S.top + 1];
}
void CStack::Clear()
{
S.top = -1;
}
BOOL CStack::IsEmpty()
{
return (S.top == -1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?