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

📄 queue.h

📁 医院模拟:经典堆栈队列应用;VC++控制台程序;小弟上数据结构是作品.
💻 H
字号:
#define Type int
#define NULL 0
/////

/////
typedef struct QueueNode
{
	Type data;
	QueueNode *next;
}QueueNode;
typedef struct ListQueue
{
	QueueNode *front;
	QueueNode *rear;
}ListQueue;

////
ListQueue *CreatListQueue()
{
	ListQueue *p=new ListQueue;
	p->front=NULL;
	p->rear=NULL;
	return p;
}

//
int IsEmpty(ListQueue *p)
{
	return p->front==NULL?1:0;
}

//
void InQueue(ListQueue *p,Type value)
{
	if(p->front==NULL) 
	{
		p->front=p->rear=new QueueNode;
		p->front->data=value;
		p->front->next=NULL;
	}
	else 
	{
		p->rear->next=new QueueNode;//无出错处理
		p->rear->next->data=value;
		p->rear=p->rear->next;
		p->rear->next=NULL;
	}
}

//
Type OutQueue(ListQueue *p)
{
	if(IsEmpty(p))
	{
		return NULL;
	}
	else 
	{
		QueueNode *q=p->front;
		Type value=q->data;
		p->front=p->front->next;
		delete q;
		return value;
	}
}

//
void MakeEmpty(ListQueue *p)
{
	QueueNode *q=p->front;
	QueueNode *r=q;
	while(q)
	{
		q=q->next;
		delete r;
		r=q;
	}
	p->front=p->rear=NULL;
}
	



⌨️ 快捷键说明

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