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

📄 rnode.cpp

📁 三个强盗和三个商人过河的算法
💻 CPP
字号:
#include "RNode.h"
#include <iostream>
#include <cmath>

using namespace std;

RNode::RNode(int nodeState) {
	this->nodeState = nodeState;
	this->fatherNode = NULL;
}

RNode::RNode(int nodeState, RNode* fatherNode) {
	this->nodeState = nodeState;
	this->fatherNode = fatherNode;
}

int RNode::getnodeState() const {
	return nodeState;
}

int RNode::move(int method) const {
	int swap = nodeState;

	switch(method) {
		case 0: //(-1, 0, 1, 0)
			return -(swap-1000+10);
		case 1: //(-2, 0, 2, 0)
			return -(swap-2000+20);
		case 2: //(0, -1, 0, 1)
			return -(swap-100+1);
		case 3: //(0, -2, 0, 2)
			return -(swap-200+2);
		case 4: //(-1, -1, 1, 1)
			return -(swap-1100+11);
	}
}

RNode* RNode::getfatherNode() const {
	return fatherNode;
}

⌨️ 快捷键说明

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