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

📄 lxastack.cpp

📁 vc编写的数据结构
💻 CPP
字号:
// lxastack.cpp: implementation of the lxastack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "lxastack.h"

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

lxastack::lxastack(int sz=defaultlistsize)
{
	size=sz;
	top=0;
	listarray=new int[sz];

}

lxastack::~lxastack()
{
	delete [] listarray;

}

void lxastack::clear()
{
	top=0;

}

bool lxastack::push(const int &item)
{
	if(top==size) return false;
	else {listarray[top++]=item;return true;}

}

bool lxastack::pop(int &it)
{
	if(top==0) return false;
	else {it=listarray[--top];return true;}

}

bool lxastack::topvalue(int &it)
{
	if(top==0)return false;
	else{it=listarray[top-1];return true;}

}

int lxastack::length() const
{
	return top;

}

⌨️ 快捷键说明

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