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

📄 stack.cpp

📁 正规(则)表达式转化为NFA
💻 CPP
字号:
// Stack.cpp: implementation of the Stack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "TONFA.h"
#include "Stack.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Stack::Stack()
{
	vec=new int[SIZE];
	maxsize=SIZE;
	top=-1;
}

Stack::~Stack()
{
	delete [] vec;
}

void Stack::Push(int state)
{
	if(top==maxsize-1)
		AfxMessageBox("Overflow");
	else
	{
		top++;
		vec[top]=state;
	}
}

int Stack::Pop()
{
	int temp;
	if(top==-1)
	{
		AfxMessageBox("underflow");
		return 0;
	}
	else
	{
		temp=vec[top];
		top--;
		return temp;
	}
}

int Stack::GetTop()
{
	if(top==-1)
	{
		AfxMessageBox("underflow");
		return 0;
	}
	else
		return vec[top];
}

void Stack::Clear()
{
	top=-1;
}

int Stack::IsEmpty()
{
	if(top==-1)
		return 1;
	else 
		return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -