?? head.h
字號:
//*********************************************
//* 8數碼問題的頭文件 *
//* 文件名稱:head.h *
//* 功 能:定義工程中的所用全局變量 *
//* 參 數: *
//* 返 回 值: *
//* 工作方式: *
//*********************************************
#if !defined(H_HEAD_H)
#define H_HEAD_H
#include <iostream>
#include <ctime>
#include <algorithm>
#include <vector>
using namespace std;
/***********用2維數組定義8數碼的盤局***********/
const int ROW=3; //const相當與#define
const int COL=3;
/***************表示節點信息的結構**************/
typedef struct Node
{
int digit[ROW][COL];
bool outofopen;
//我們定義的function=dist+dep
int index; // 指向父節點的指針
} Node;
Node src,dest; //分別存放初始節點和目標節點
vector<Node> node_v; //容器,可以存放任意個node對象,作為open表和close表使用
//**********輸出函數重定義****************//
ostream &operator<<(ostream &os, Node& node)
{
for(int i=0;i<ROW;i++)
{
for(int j=0;j<COL;j++)
os<<node.digit[i][j]<<' ';
os<<endl;
}
return os;
}
bool isEmptyOfOPEN();
bool isEqual(int index, int digit[][COL]);
void PrintSteps(int index, vector<Node>& rstep_v);
void Swap(int& a, int& b);
void Assign(Node& node, int index);
bool isExpandable(Node& node);
void ProcessNode(int index);
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -