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

📄 queue.cpp

📁 本程序在visual c++环境下实现二叉树的层次遍历.
💻 CPP
字号:
// queue.cpp: implementation of the queue class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "queue.h"
#include "Tree.h"
#include "stdlib.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

queue::queue()
{
	head = rear = NULL;
}

queue::~queue()
{

}
//向队列中添加新的元素。
void queue::Add_Queue( binode * element)
{
	struct node * q;
	q = (struct node *) malloc (sizeof(struct node));
	q->item = element ;
	q->next = NULL;
	if(rear==NULL)
		rear = q;
	else
	{
		rear->next = q;   /**/
		rear = q;
	}
	if(head==NULL) 
		head = rear;
}

//从队列中删除元素
binode * queue::Del_Queue()
{
	struct binode * q;
	q = (struct binode *) malloc (sizeof(struct binode));
	q = head->item;
	head = head->next;
	return q;
}

⌨️ 快捷键说明

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