C语言核心知识点Day09

1.栈

1.1栈的基本概念
	栈是一个线性表,栈元素具有线性关系,即前驱后继关系。只不过它是一种特殊的
线性表而已。在线性表的表尾进行插入和删除操作,当对象为栈的时候,这里表尾是
指栈顶,而不是栈底。栈的特殊之处在于限制了这个线性表的插入和删除的位置,它
始终只在栈顶进行。这也就使得:栈底是固定的,最先进栈的只能在栈底。也就是说
这是一种先进后出的模型。

1.2栈的顺序存储
	栈的顺序存储结构简称顺序栈,它是运算受限制的顺序表。顺序栈的存储结构是:
利用一组地址连续的的存储单元依次存放自栈底到栈顶的数据元素,同时附设指针
top只是栈顶元素在顺序表中的位置。
	(其中)当使用栈的顺序存储的时候,栈的首元素代表的是栈底元素。

1.3 栈顶顺序存储的实现
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#define MAX 1024

//顺序栈结构体
struct SStack
{
	void* buffer[MAX];
	int m_size;
};

//创建变量结构体
struct Person
{
	char name[64];
	int age;
};

//初始化操作
void* init_Stack()
{
	struct SStack* m_stack = malloc(sizeof(struct SStack));
	if (m_stack == NULL)
		return NULL;


	//属性初始化
	memset(m_stack->buffer, 0, sizeof(void*) * MAX);
	m_stack->m_size = 0;

	return m_stack;
}

//入栈
void push_Stack(struct SStack* m_stack,void* value)
{
	if (m_stack == NULL || value == NULL)
		return;

	//判断是否栈满
	struct SStack* stack1 = m_stack;
	if (stack1->m_size == MAX)
		return;

	//插入元素
	stack1->buffer[stack1->m_size] = value;
	stack1->m_size++;
}

//出栈
void* pop_Stack(struct SStack* m_stack)
{
	if (m_stack == NULL)
		return NULL;

	struct SStack* stack1 = m_stack;
	//栈空
	if (stack1->m_size == 0)
		return NULL;

	//临时变量接收出栈元素
	void* tempValue = stack1->buffer[stack1->m_size - 1];

	//栈内出栈元素置空,栈长度减少
	stack1->buffer[stack1->m_size - 1] = NULL;
	stack1->m_size--;

	return tempValue;
}

//返回栈顶
void* top_Stack(struct SStack* m_stack)
{
	if (m_stack == NULL)
		return NULL;

	struct SStack* stack1 = m_stack;
	//栈空
	if (stack1->m_size == 0)
		return NULL;

	return stack1->buffer[stack1->m_size - 1];
}

//返回栈大小
int size_Stack(struct SStack* m_stack)
{
	if (m_stack == NULL)
		return 0;

	struct SStack* stack1 = m_stack;

	return stack1->m_size;
}

//判断栈是否为空
int empty_Stack(struct SStack* m_stack)
{
	if (m_stack == NULL)
		return -1;

	struct SStack* stack1 = m_stack;

	//返回值1代表为空,0代表不为空
	if (stack1->m_size == 0)
		return 1;
	return 0;
}

//销毁
void destroy_Stack(struct SStack* m_stack)
{
	if (m_stack == NULL)
		return;

	free(m_stack);
	m_stack = NULL;
}

//弹出元素测试
void myPrint(void* value)
{
	struct Person* p1 = value;
	printf("姓名:%s,年龄:%d\n", p1->name, p1->age);
}

//测试
void test01()
{
	//创建栈
	struct SStack* m_stack = init_Stack();

	//创建变量
	struct Person p1 = { "张三",22 };
	struct Person p2 = { "李四",23 };
	struct Person p3 = { "王五",21 };
	struct Person p4 = { "赵六",19 };
	struct Person p5 = { "孙起",20 };

	//入栈
	push_Stack(m_stack, &p1);
	push_Stack(m_stack, &p2);
	push_Stack(m_stack, &p3);
	push_Stack(m_stack, &p4);
	push_Stack(m_stack, &p5);

	//显示大小
	printf("栈内元素个数为:%d\n", size_Stack(m_stack));

	//出栈测试
	myPrint(pop_Stack(m_stack));
	myPrint(pop_Stack(m_stack));
	myPrint(pop_Stack(m_stack));
	myPrint(pop_Stack(m_stack));
	myPrint(pop_Stack(m_stack));

	//显示大小
	printf("栈内元素个数为:%d\n", size_Stack(m_stack));

	//栈是否为空
	if (empty_Stack(m_stack) == 1)
		printf("栈已经为空!");
	else
		printf("栈不为空/传入参数有问题!");

	//销毁栈
	destroy_Stack(m_stack);
}

int main()
{
	test01();
	return 0;
}
1.4栈的链式存储
	栈的链式存储结构简称链栈。由于单链表有头指针,而栈顶指针也是必须的,因此,
可以将二者何在一起使用,比较好的办法就是把栈顶放在单链表的头部。另外都已经
有了栈顶在头部了,单链表中比较常用的头结点也就失去了意义,通常对于链栈来说
,是不需要头结点的。

1.5 栈的链式存储的实现
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include

//定义链栈的时候,我们应该将头结点指向栈顶,通过头结点来维护进出栈的数据
//创建结点结构体
struct LinkNode
{
	struct LinkNode* next;//指针域
};

//创建链栈的结构体
struct LinkStack
{
	struct LinkNode shead;//头结点
	int m_size;

};
//创建变量结构体
struct Person
{
	struct LinkNode* next;
	char namr[64];
	int age;
};

//初始化
void* init_Linkstack()
{
	//创建链栈
	struct LinkStack* m_stack = malloc(sizeof(struct LinkStack));
	if (m_stack == NULL)
		return NULL;

	//初始化属性
	m_stack->m_size = 0;
	m_stack->shead.next = NULL;

	return m_stack;
}

//入栈(相当于头插)
void push_LinkStack(struct LinkStack* m_stack,void * value)
{
	if (m_stack == NULL || value == NULL)
		return;

	//改变指向
	struct LinkNode* m_value = value;

	// 更新新结点的next域
	m_value->next = m_stack->shead.next;
	//头指针指向新结点
	m_stack->shead.next = m_value;

	m_stack->m_size++;
}

//出栈
void pop_LinkStack(struct LinkStack* m_stack)
{
	if (m_stack == NULL || m_stack->m_size == 0)
		return;

	//指向栈顶元素
	struct LinkNode* pCurrent = m_stack->shead.next;

	//头指针指向栈顶元素的下一个元素
	m_stack->shead.next = pCurrent->next;

	m_stack->m_size--;
}

//返回栈顶元素
void* top_LinkStack(struct LinkStack* m_stack)
{
	if (m_stack == NULL || m_stack->m_size == 0)
		return NULL;

	return m_stack->shead.next;
}

//是否为空
int empty_LinkStack(struct LinkStack* m_stack)
{
	//传入数据是否正确
	if (m_stack == NULL)
		return -1;

	//判断元素是否为空 为空返回1,不为空返回0
	if (m_stack->m_size == 0)
		return 1;
	return 0;
}

//栈大小
int size_LinkStack(struct LinkStack* m_stack)
{
	//传入数据是否正确
	if (m_stack == NULL)
		return -1;

	return m_stack->m_size;
}

//销毁栈
void destroy_LinkStack(struct LinkStack* m_stack)
{
	if (m_stack == NULL)
		return;

	free(m_stack);
	m_stack = NULL;
}

//测试
void test01()
{
	//创建栈
	struct LinkStack* m_stack = init_Linkstack();

	//创建变量
	struct Person p1 = { NULL,"张三",22 };
	struct Person p2 = { NULL,"李四",23 };
	struct Person p3 = { NULL,"王五",21 };
	struct Person p4 = { NULL,"赵六",19 };
	struct Person p5 = { NULL,"孙起",20 };

	//入栈
	push_LinkStack(m_stack, &p1);
	push_LinkStack(m_stack, &p2);
	push_LinkStack(m_stack, &p3);
	push_LinkStack(m_stack, &p4);
	push_LinkStack(m_stack, &p5);

	//显示大小
	printf("栈内元素个数为:%d\n", size_LinkStack(m_stack));

	//不为空时
	while (empty_LinkStack(m_stack) == 0)
	{
		//接收栈顶元素
		struct Person* temp1 = top_LinkStack(m_stack);
		printf("姓名:%s,年龄:%d\n",temp1->namr,temp1->age);
		//出栈
		pop_LinkStack(m_stack);
	}

	//显示大小
	printf("栈内元素个数为:%d\n", size_LinkStack(m_stack));

	//栈是否为空
	if (empty_LinkStack(m_stack) == 1)
		printf("栈已经为空!");
	else
		printf("栈不为空/传入参数有问题!");

	//销毁栈
	destroy_LinkStack(m_stack);
}

int main()
{
	test01();
	return 0;
}
1.6 案例:就近匹配(编译器可以在()不匹配的时候报错,运用了栈的原理)
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
//案例:编译器中括号就近匹配的原则
//用“|”指出出现错误的位置,显示错误信息
//正确字符串不做操作


//创建结点结构体
struct LinkNode
{
	struct LinkNode* next;//指针域
};

//创建链栈的结构体
struct LinkStack
{
	struct LinkNode shead;//头结点
	int m_size;

};

//初始化
void* init_Linkstack()
{
	//创建链栈
	struct LinkStack* m_stack = malloc(sizeof(struct LinkStack));
	if (m_stack == NULL)
		return NULL;

	//初始化属性
	m_stack->m_size = 0;
	m_stack->shead.next = NULL;

	return m_stack;
}

//入栈
void push_LinkStack(struct LinkStack* m_stack,void * value)
{
	if (m_stack == NULL || value == NULL)
		return;

	//改变指向
	struct LinkNode* m_value = value;

	// 更新新结点的next域
	m_value->next = m_stack->shead.next;
	//头指针指向新结点
	m_stack->shead.next = m_value;

	m_stack->m_size++;
}

//出栈
void pop_LinkStack(struct LinkStack* m_stack)
{
	if (m_stack == NULL || m_stack->m_size == 0)
		return;

	//指向栈顶元素
	struct LinkNode* pCurrent = m_stack->shead.next;

	//头指针指向栈顶元素的下一个元素
	m_stack->shead.next = pCurrent->next;

	m_stack->m_size--;
}

//返回栈顶元素
void* top_LinkStack(struct LinkStack* m_stack)
{
	if (m_stack == NULL || m_stack->m_size == 0)
		return NULL;

	return m_stack->shead.next;
}

//是否为空
int empty_LinkStack(struct LinkStack* m_stack)
{
	//传入数据是否正确
	if (m_stack == NULL)
		return -1;

	//判断元素是否为空 为空返回1,不为空返回0
	if (m_stack->m_size == 0)
		return 1;
	return 0;
}

//栈大小
int size_LinkStack(struct LinkStack* m_stack)
{
	//传入数据是否正确
	if (m_stack == NULL)
		return -1;

	return m_stack->m_size;
}

//销毁栈
void destroy_LinkStack(struct LinkStack* m_stack)
{
	if (m_stack == NULL)
		return;

	free(m_stack);
	m_stack = NULL;
}

//测试
void test01()
{
	//创建栈
	struct LinkStack* m_stack = init_Linkstack();

	//创建变量
	char ch[64] = "3*1+(6*2)*(8/4)6-2(";
	char temparr[64];
	int i;

	//遍历数组
	for (i = 0; i < strlen(ch); ++i)
	{
		//如果等于),进行一次入栈操作;如果等于),进行一次出栈操作
		memset(temparr, 0, 64);
		memcpy(temparr, ch, 64);
		if (temparr[i] == '(')
		{
			push_LinkStack(m_stack, &temparr[i]);
		}
		if (temparr[i] == ')')
		{
			if (top_LinkStack(m_stack) == NULL)
			{
				printf("匹配失败!(错误1:先有的)符号):\n");

				printf("%s\n", ch);
				if (i != (strlen(ch) - 1))
				{
					for (int j = 0; j < i; j++)
					{
						printf(" ");
					}
					printf("|\n");
				}


				return;
			}
			pop_LinkStack(m_stack);
		}
	}


	显示大小
	//printf("栈内元素个数为:%d\n", size_LinkStack(m_stack));

	//不为空时
	if(empty_LinkStack(m_stack) == 0)
	{
		printf("字符串不合格!(错误2:仅有(符号):\n");
		printf("%s\n", ch);
		if (i != (strlen(ch) - 1))
		{
			for (int j = 0; j < i - 1; j++)
			{
				printf(" ");
			}
			printf("|\n");
		}

		destroy_LinkStack(m_stack);
		return;
	}
	else
	{
		destroy_LinkStack(m_stack);
		return;
	}
}

int main()
{
	test01();
	return 0;
}


2.队列

2.1队列基本概念
	队列是一种特殊的受限制的线性表。  队列是只允许在一端进行插入操作,而在
另一端进行删除操作的线性表。它是一种先进先出的特殊的的线性表,简称FIFO。
允许插入的一端为队尾(尾插),允许删除的一端为队头(头删)。队列不允许在
中间部位进行操作,仅仅允许在队头和队尾进行相应的操作。

2.2 队列的顺序存储
	由之前写好的动态数组的代码直接封装即可,很多功能的实现用之前动态数组中
写好的功能就行。
#pragma  once
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include

#define  MAX 1024

typedef void * seqQueue;
//动态数据结构体
struct dynamicArray
{
	void ** pAddr; // 维护开辟到堆区真实数组的指针

	int m_Capacity; //数组容量

	int m_Size; //数组大小
};

//初始化数组 参数代表 初始化的容量
struct dynamicArray * init_dynamicArray(int capacity);

//插入元素
void insert_dynamicArray(struct dynamicArray * arr, int pos, void * data);

//遍历数组
void foreach_dynamicArray(struct dynamicArray * arr, void(*myPrint)(void *));

//删除数组
void removeByPos_dynamicArray(struct dynamicArray * arr, int pos);

//按照值 来删除数组中数据
void removeByValue_dynamicArray(struct dynamicArray * arr, void * data, int(*myCompare)(void *, void *));

//销毁数组
void destroy_dynamicArray(struct dynamicArray * arr);

//初始化队列
seqQueue init_SeqQueue();
//入队
void push_SeqQueue( seqQueue queue , void * data);
//出队
void pop_SeqQueue(seqQueue queue);
//返回队头元素
void * front_SeqQueue(seqQueue queue);

//返回队尾元素
void * back_SeqQueue(seqQueue queue);

//队列大小
int size_SeqQueue(seqQueue queue);

//判断是否为空
int isEmpty_SeqQueue(seqQueue queue);

//销毁队列
void destroy_SeqQueue(seqQueue queue);

struct Person
{
	char name[64];
	int age;
};

void test01()
{
	//初始化队列
	seqQueue myQueue = init_SeqQueue();

	//准备数据
	struct Person p1 = { "aaa", 10 };
	struct Person p2 = { "bbb", 20 };
	struct Person p3 = { "ccc", 30 };
	struct Person p4 = { "ddd", 40 };
	struct Person p5 = { "eee", 50 };

	//入队
	push_SeqQueue(myQueue, &p1);
	push_SeqQueue(myQueue, &p2);
	push_SeqQueue(myQueue, &p3);
	push_SeqQueue(myQueue, &p4);
	push_SeqQueue(myQueue, &p5);

	printf("队列大小为:%d\n", size_SeqQueue(myQueue));

	while (isEmpty_SeqQueue(myQueue) == 0) 
	{
		//队头元素
		struct Person * pFront =  front_SeqQueue(myQueue);
		printf("队头元素姓名:%s 年龄:%d \n", pFront->name, pFront->age);

		//队尾元素
		struct Person * pBack = back_SeqQueue(myQueue);
		printf("队尾元素姓名:%s 年龄:%d \n", pBack->name, pBack->age);

		//出队
		pop_SeqQueue(myQueue);
	}

	printf("队列大小为:%d\n", size_SeqQueue(myQueue));

	//销毁队列
	destroy_SeqQueue(myQueue);
	myQueue = NULL;
}

int main(){

	test01();

	system("pause");
	return EXIT_SUCCESS;
}

//初始化数组 参数代表 初始化的容量
struct dynamicArray * init_dynamicArray(int capacity)
{
	struct dynamicArray * array = malloc(sizeof(struct dynamicArray));

	if (array == NULL)
	{
		return NULL;
	}

	//给数组属性初始化
	array->m_Capacity = capacity;
	array->m_Size = 0;
	array->pAddr = malloc(sizeof(void *)* capacity);

	if (array->pAddr == NULL)
	{
		return NULL;
	}

	return array;
}


//插入元素
void insert_dynamicArray(struct dynamicArray * arr, int pos, void * data)
{
	if (arr == NULL)
		return;
	if (data == NULL)
		return;
	if (pos < 0 || pos > arr->m_Size)
		pos = arr->m_Size;
	//判断是否有空间进行插入,如果没有空间了,那么动态扩展
	if (arr->m_Size >= arr->m_Capacity)
	{
		int newCapacity = arr->m_Capacity * 2;
		//创建新空间
		void ** newSpace = malloc(sizeof (void *)* newCapacity);
		//将原有数据拷贝到新空间下
		memcpy(newSpace, arr->pAddr, sizeof(void*)* arr->m_Capacity);
		free(arr->pAddr);
		arr->pAddr = newSpace;
		arr->m_Capacity = newCapacity;
	}
	//插入数据
	for (int i = arr->m_Size - 1; i >= pos; i--)
	{
		//数据后移
		arr->pAddr[i + 1] = arr->pAddr[i];
	}
	//将新数据放入到指定位置中
	arr->pAddr[pos] = data;
	//更新数组大小
	arr->m_Size++;
}

//遍历数组
void foreach_dynamicArray(struct dynamicArray * arr, void(*myPrint)(void *))
{
	if (arr == NULL)
		return;
	if (myPrint == NULL)
		return;
	for (int i = 0; i < arr->m_Size; i++)
		myPrint(arr->pAddr[i]);
}


//删除数组
void removeByPos_dynamicArray(struct dynamicArray * arr, int pos)
{
	if (arr == NULL)
		return;
	if (pos < 0 || pos >arr->m_Size - 1)
		return;
	for (int i = pos; i < arr->m_Size - 1; i++)
	{
		arr->pAddr[i] = arr->pAddr[i + 1];
	}
	//更新大小
	arr->m_Size--;
}

//按照值 来删除数组中数据
void removeByValue_dynamicArray(struct dynamicArray * arr, void * data, int(*myCompare)(void *, void *))
{
	if (arr == NULL)
		return;

	if (data == NULL)
		return;
	for (int i = 0; i < arr->m_Size; i++)
	{
		if (myCompare(arr->pAddr[i], data))
		{
			//如果对比成功了,那么要删除i下标的元素
			removeByPos_dynamicArray(arr, i);
			break;
		}
	}
}

//销毁数组
void destroy_dynamicArray(struct dynamicArray * arr)
{
	if (arr == NULL)
		return;
	if (arr->pAddr != NULL)
	{
		free(arr->pAddr);
		arr->pAddr = NULL;
	}
	free(arr);
	arr = NULL;
}

//初始化队列
seqQueue init_SeqQueue()
{
	struct dynamicArray * array = init_dynamicArray(MAX);
	return array;
}
//入队
void push_SeqQueue(seqQueue queue, void * data)
{
	//等价于 尾插
	if (queue == NULL)
		return;
	if (data == NULL)
		return;
	struct dynamicArray * array = queue;
	if (array->m_Size >= MAX)
		return;
	insert_dynamicArray(array, array->m_Size, data);
}
//出队
void pop_SeqQueue(seqQueue queue)
{
	//等价于  头删除
	if (queue == NULL)
		return;
	struct dynamicArray * array = queue;
	if (array->m_Size <= 0)
		return;
	removeByPos_dynamicArray(array, 0);
}
//返回队头元素
void * front_SeqQueue(seqQueue queue)
{
	if (queue == NULL)
		return NULL;

	struct dynamicArray * array = queue;
	return array->pAddr[0];
}

//返回队尾元素
void * back_SeqQueue(seqQueue queue)
{
	if (queue == NULL)
		return NULL;
	struct dynamicArray * array = queue;	
	return array->pAddr[array->m_Size - 1];
}

//队列大小
int size_SeqQueue(seqQueue queue)
{
	if (queue == NULL)
		return -1;
	
	struct dynamicArray * array = queue;
	return array->m_Size;
}

//判断是否为空
int isEmpty_SeqQueue(seqQueue queue)
{
	if (queue == NULL)
		return -1;
	struct dynamicArray * array = queue;
	if (array->m_Size == 0)
		return 1;
	return 0;
}

//销毁队列
void destroy_SeqQueue(seqQueue queue)
{
	if (queue == NULL)
		return ;
	destroy_dynamicArray(queue);
	queue = NULL;
}

2.3 队列的链式存储
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include


//创建结点结构体
struct Person
{
	char name[64];
	int age;
};

//创建顺序队列结构体
struct LinkQueue
{
	//struct LinkQueue* qHead;
	//struct LinkQueue* qTail;

	//指针域
	struct LinkQueue* next;
	//数据域
	void* data;

	int m_size;

};

//初始化
void* init_Queue()
{
	//开辟空间
	struct LinkQueue* m_queue = malloc(sizeof(struct LinkQueue));
	if (m_queue == NULL)
		return NULL;

	//属性赋值
	m_queue->data = NULL;
	m_queue->next = NULL;
	m_queue->m_size = 0;

	return m_queue;
}

//入队
void push_Queue(struct LinkQueue* m_queue,void* value)
{
	if (m_queue == NULL || value == NULL)
		return;

	//找到尾部
	struct LinkQueue* m_tail = m_queue;
	for (int i = 0; i < m_queue->m_size; ++i)
	{
		m_tail = m_tail->next;
	}

	//创建一个新结点
	struct LinkQueue* new_Value = malloc(sizeof(struct LinkQueue));
	m_tail->next = new_Value;
	new_Value->data = value;
	new_Value->next = NULL;

	m_queue->m_size++;

}

//出队
void pop_Queue(struct LinkQueue* m_queue)
{
	if (m_queue == NULL)
		return;

	if (m_queue->m_size == 0)
		return;

	//找出头部指针
	struct LinkQueue* pCurrent = malloc(sizeof(struct LinkQueue));
	pCurrent = m_queue->next;
	//更新位置
	m_queue->next = pCurrent->next;

	m_queue->m_size--;
	
	free(pCurrent);
	pCurrent = NULL;

}

//返回队头
void* front_Queue(struct LinkQueue* m_queue)
{
	if (m_queue == NULL)
		return NULL;
	if (m_queue->m_size == 0)
		return NULL;

	struct LinkQueue* pCurrent = m_queue->next;
	//更新位置
	return pCurrent->data;

}

//返回队尾
void* back_Queue(struct LinkQueue* m_queue)
{
	if (m_queue == NULL)
		return NULL;
	if (m_queue->m_size == 0)
		return NULL;

	//找到尾部
	struct LinkQueue* m_tail = m_queue;
	for (int i = 0; i < m_queue->m_size; ++i)
	{
		m_tail = m_tail->next;
	}

	return m_tail->data;

}

//返回队大小
int size_Queue(struct LinkQueue* m_queue)
{
	if (m_queue == NULL)
		return -1;

	return m_queue->m_size;
}

//判断是否为空
int empty_Queue(struct LinkQueue* m_queue)
{
	if (m_queue == NULL)
		return -1;

	if (m_queue->m_size == 0)
		return 1;
	return 0;
}

//销毁
void destroy(struct LinkQueue* m_queue)
{
	if (m_queue == NULL)
		return;

	free(m_queue);
	m_queue = NULL;
}

void test01()
{

	//初始化
	struct LinkQueue* m_queue = init_Queue();

	//创建变量
	struct Person p1 = {"张三",22 };
	struct Person p2 = {"李四",23 };
	struct Person p3 = {"王五",21 };
	struct Person p4 = {"赵六",19 };
	struct Person p5 = {"孙起",20 };

	//入队
	push_Queue(m_queue, &p1);
	push_Queue(m_queue, &p2);
	push_Queue(m_queue, &p3);
	push_Queue(m_queue, &p4);
	push_Queue(m_queue, &p5);


	while (empty_Queue(m_queue) == 0)
	{

		pop_Queue(m_queue);
		if (m_queue->m_size == 0)
			break;
		//printf("%d\n", m_queue->m_size);
		//取队头元素
		struct Person* temp1 = front_Queue(m_queue);
		printf("队头元素的姓名:%s,年龄:%d\n", temp1->name, temp1->age);
		//队尾元素
		struct Person* temp2 = back_Queue(m_queue);
		printf("队尾元素的姓名:%s,年龄:%d\n", temp2->name, temp2->age);
		//长度
		printf("队内的元素个数为:%d\n", size_Queue(m_queue));
		//pop_Queue(m_queue);
	}
	//销毁
	destroy(m_queue);

}

int main()
{
	test01();
	return 0;
}

你可能感兴趣的:(C++学习,数据结构)