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

📄 sqstack.cpp

📁 VC++编的数据结构 魔王语言解释,可以输入多对括号,已经在VC编译通过
💻 CPP
字号:
// SqStack.cpp: implementation of the SqStack class.
//
//////////////////////////////////////////////////////////////////////

#include "SqStack.h"

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

SqStack::SqStack()
{
	top=base=new Node;
}

SqStack::~SqStack()
{

}

bool SqStack::push(char e)
{   Node *p=new Node;
	if(p==NULL)
	{  cout<<"Stack is overflow"<<endl;
	   return false;
	}
	else
	{  p->word=e;
	   p->next=top;
	   top=p;
	   return true;
	}
}

bool SqStack::pop(char& e)
{   
	if(top==NULL)
	{  cout<<"Stack is empty"<<endl;
	   return false;
	}
	else
	{  Node *p=top;
	   top=top->next;
	   e=p->word;
	   delete p;
	   return true;
	}
}

bool SqStack::StackEmpty()
{   return top==base;
}

⌨️ 快捷键说明

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