博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
j.c.Warnsdorff马踏棋盘算法
阅读量:4697 次
发布时间:2019-06-09

本文共 796 字,大约阅读时间需要 2 分钟。

/*#include

include”queue.h”

struct point {

int x;//马的x方向
int y;//马的y方向
};

typedef struct Queue{

struct point queue[MaxQueueSize];
int front;//头指针
int rear;//尾指针
int tag;//设置标记位
}SeqCQueue;

//初始化队列操作

void QueueInitiate(SeqCQueue *Q){
Q->front=0;
Q->rear=0;
Q->tag=0;
}

//判断队列是否为空

int QueueNotEmpty(SeqCQueue Q){
if(Q.front==Q.rear&&Q.tag==0)
return 0;
else
return 1;
}

//入队操作

void QueueAppend(SeqCQueue *Q,point x){
if(Q->tag==1&&Q->front==Q->rear){
printf(“队列已满,无法插入!\n”);
}else {
Q->queue[Q->rear]=x;
Q->rear=(Q->rear+1)%MaxQueueSize;
Q->tag=1;
}
}

//出队操作

void QueuePop(SeqCQueue *Q,point *d){
if(Q->tag==0&&Q->front==Q->rear){
printf(“队列已空,无元素可以出队列!\n”);
}else {
*d=Q->queue[Q->front];
Q->front=(Q->front+1)%MaxQueueSize;
Q->tag=0;
}
}

#include

转载于:https://www.cnblogs.com/Wu-Shi/p/5410068.html

你可能感兴趣的文章