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

📄 ninebox.cpp

📁 八数码问题的求解八数码问题的求解八数码问题的求解八数码问题的求解
💻 CPP
字号:
// NineBox.cpp: implementation of the NineBox class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Eight.h"
#include "NineBox.h"

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

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

NineBox::NineBox()
{
	ResetValue();
}

NineBox::~NineBox()
{
	
}

void NineBox::MoveUp()
{
	int x,y;
	this->GetXYByValue(0,x,y);

	if (x>0) 
	{
		this->swap(x,y,x-1,y);move_type=1;
	}

	
}

void NineBox::MoveDown()
{
	int x,y;
	this->GetXYByValue(0,x,y);
	
	if (x<2) 
	{
		this->swap(x,y,x+1,y);move_type=2;
	}
	
}

void NineBox::MoveLeft()
{
	int x,y;
	this->GetXYByValue(0,x,y);
	
	if (y>0) 
	{
		this->swap(x,y,x,y-1);move_type=3;
	}
	
}

void NineBox::MoveRight()
{
	int x,y;
	this->GetXYByValue(0,x,y);
	
	if (y<2) 
	{
		this->swap(x,y,x,y+1);move_type=4;
	}
	this->GetXYByValue(0,x,y);
}

⌨️ 快捷键说明

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