队列概念
队列是对头出、队尾入的先进先出线性表。
需要两个指针front和rear分别来指向队头和队尾。
front指向队头元素的前一个位置,rear总是指向队尾元素。
进队:rear+1
出队:front+1
队空条件:front=rear
队满条件:rear = MaxSize - 1
代码
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define ERROR 0
#define OK 1
#define ElemeType_SQu int //顺序栈数据类型
#define MaxSize_SQu 100 //顺序栈最大容量
typedef int status;
typedef struct {
ElemeType_SQu data[MaxSize_SQu];
int front;//队首
int rear;//队尾
}QuType,*Queue;
void InitQueue_ln(Queue& qu)
{
qu = (Queue)ma