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

📄 horse_head.h

📁 马踏棋盘的程序设计 设计一个国际象棋的马踏遍棋盘的演示程序。 将马随机放在国际象棋的8×8棋盘Board[8][8]的某个方格中
💻 H
字号:
#if	!defined	HORSE_HEAD
#define			HORSE_HEAD	
#include <windows.h>
#include<stdio.h>
#include<malloc.h>
#include<string.h>

//the eight directions of a horse can run
#define		LEFT_UP			1
#define		UP_LEFT			2
#define		DOWN_LEFT		3
#define		LEFT_DOWN		4
#define		RIGHT_DOWN		5
#define		DOWN_RIGHT		6
#define		UP_RIGHT		7
#define		RIGHT_UP		8


#define		CHESSBOARD			8 //the width and height of chessboard
#define		STACK_TOTAL			64
#define		STACK_INCREMENT		20

typedef		int	chessboard[CHESSBOARD][CHESSBOARD];	

typedef		struct	step{
	int	x,y;   //the x-postion and y-position of a step
	int	direction;//the last direction has stepped
} * pStep;

struct	stack_step{
		pStep	pBase;
		pStep	pTop;
		int		total_size;
};


void SetPos(int nX, int nY);
void frame(int x, int y, int width, int height);



// the funcions below  operate on stack_step;

void	Init_Stack(stack_step& steps);
bool	IsEmpty(stack_step steps);
bool	Push(stack_step& steps, step s);
bool	Popup(stack_step& steps, step& s);
void	GetTop(stack_step& steps,step& s);
bool	Converse(stack_step& steps_src,stack_step& steps_dest);
void	Destroy(stack_step&	steps);

//the  function below  operate on getting	the initial position of horse
void	Get_Position(int& x,int& y);

bool	Can_Move(chessboard	cb,int x,int y,int dir);
//the function below is the kernel of this program
void	Move(int& x,int& y,int dir);
void	Kernel_Run(chessboard chess,stack_step& steps,int x,int y);
void	Show(stack_step& steps/*the order in steps is right*/,int y);




#endif

⌨️ 快捷键说明

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