标签:结构 next element 数据 queue 队列 div 有一个 ror
//顺环队列 头出尾进 #define MaxSize 100 struct QNode { ElementType Data[MaxSize]; int rear; //尾 int front; //头 }; typedef struct QNode *Queue; //入队列 void AddQ ( Queue PtrQ, ElementType item ) { if ( (PtrQ->rear+1) % MaxSize == PtrQ->front ) { printf("队列满"); return; } PtrQ->rear = (PtrQ->rear+1) % MaxSize; //移尾 PtrQ->Data[PtrQ->rear] = item; //入队 } //出队列 ElementType DeleteQ ( Queue PtrQ ) { if ( PtrQ->front == PtrQ->rear ) { printf("队列空"); return ERROR; } else { PtrQ->front = (PtrQ->front+1) % MaxSize; return PtrQ->Data[PtrQ->front]; } }
struct Node { ElementType Data; struct Node *Next; }; struct QNode { struct Node *rear; struct Node *front; }; typedef struct QNode *Queue; Queue PtrQ; //出队 ElementType DeleteQ ( Queue PtrQ ) { struct Node *FrontCell; ElementType FrontElem; if ( PtrQ->front == NULL ) { printf("队列空"); return ERROR; } FrontCell = PtrQ->front; if ( PtrQ->front == PtrQ->rear ) //队列只有一个元素 PtrQ->front = PtrQ->rear = NULL; else PtrQ->front = PtrQ->front->Next; FrontElem = FrontCell->Data; free(FrontCell); return FrontElem; }
标签:结构 next element 数据 queue 队列 div 有一个 ror
原文地址:https://www.cnblogs.com/Pio-GD/p/14379428.html