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

📄 stack.cpp

📁 顺序栈
💻 CPP
字号:

#include "stack.h"

Error_code aStack::push (const Stack_entry&item)
{
	Error_code outcome=success;
	if (count>=maxstack)
	{
		outcome=overflow;
	}
	else
		entry[count++]=item;
	return outcome;
}
/***************************************/
Error_code aStack::pop ()
{
	Error_code outcome=success;
	if (count==0)
	{
		outcome=underflow;
	}
	else --count;
	return outcome;
}
/*******************************************/
Error_code aStack::top (Stack_entry&item) const
{
	Error_code outcome=success;
	if(outcome==0)
	{
		outcome=underflow;
	}
	else 
		item=entry[count-1];
	return outcome;
}
/**************************************/
bool aStack::empty() const
{
	bool outcome=true;
	if (count>0)
	{
		outcome=false;
	}
	return outcome;
}
/****************************/
aStack::aStack()
{
	count=0;//initialized the stack
}



⌨️ 快捷键说明

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