Cyclic queue (c)
# Include
Using namespace std; # define MAXSIZE 50 typedef int QueueElementType; typedef struct {QueueElementType elem [MAXSIZE]; int front; // point to the int rear element in the current queue header; // point to the next position of the End Element} SeqQueue; void InitQueue (SeqQueue & Q); void InputQueue (SeqQueue & Q); bool EnterQueue (SeqQueue & Q, QueueElementType x ); queueElementType DeleteQueue (SeqQueue & Q); QueueElementType BackQueue (SeqQueue Q); // return bool IsFull (SeqQueue Q); bool IsEmpty (SeqQueue Q ); void OutputQueue (SeqQueue Q); int QueueLength (SeqQueue Q); int main () {int x; SeqQueue q; InitQueue (q); InputQueue (q ); x = BackQueue (q); cout <"team end element:" <
> M; while (m! =-1) {if (IsFull (Q) cout <"the current queue is full and cannot be inserted" <
> M ;}} bool EnterQueue (SeqQueue & Q, QueueElementType x) {if (Q. rear + 1) % MAXSIZE = Q. front) return false; Q. elem [Q. rear] = x; Q. rear = (Q. rear + 1) % MAXSIZE; return true;} QueueElementType DeleteQueue (SeqQueue & Q) {if (IsEmpty (Q) {cout <"the current queue is empty. An error occurred while exiting the queue! "<