stack.cpp

来自「两个人工智能小程序」· C++ 代码 · 共 66 行

CPP
66
字号
// Stack.cpp: implementation of the CStack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AIWork1.h"
#include "Stack.h"

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

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

CStack::CStack()
{
	top=0;
}

CStack::~CStack()
{

}
int CStack::Length()
{
	return top;
}
int CStack::PopDirection()
{
	top--;
	if(top>=0)
		return data[top].direction;
	return -1;
}
void CStack::Push(datastruct m_data)
{
	data[top]=m_data;
	top++;
}

datastruct CStack::IndexValue(int index)
{
	if(index<top)
		return data[index];
	else
	{
		datastruct defaultvalue;
		for(int i=0;i<16;i++)
		{
			for(int j=0;j<16;j++)
				defaultvalue.datakey[i][j]=-1;
		}
		defaultvalue.direction=-1;
		return defaultvalue;
	}
}

void CStack::Init()
{
	top=0;
}

⌨️ 快捷键说明

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