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

📄 stack.cpp

📁 关于栈的操作的小程序
💻 CPP
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -