环形队列 出入队怎么写

环形队列 进队入队这里 怎么写
#include <stdio.h>
#include <malloc.h>
#define MaxSize 5
typedef char ElemType;
typedef struct
{
ElemType data[MaxSize];
int front,rear; //队首和队尾指针
} SqQueue;
void InitQueue(SqQueue *&q) //初始化队列
{ q=(SqQueue *)malloc (sizeof(SqQueue));
q->front=q->rear=0;
}
void DestroyQueue(SqQueue *&q) //销毁队列
{
free(q);
}
bool QueueEmpty(SqQueue *q) //判断队列空
{
return(q->front==q->rear);
}
bool enQueue(SqQueue *&q,ElemType e) //进队
{
/BEGIN/

/******END******/

}
bool deQueue(SqQueue *&q,ElemType &e) //出队
{
/BEGIN/

/******END******/

}
int main()
{
int i,n;
ElemType ch,e;
SqQueue *q;
InitQueue(q);
scanf("%d\n",&n);
for(i=0;i<n;i++)
{
scanf("%c",&ch);
if (!enQueue(q,ch)) printf("提示:队满,不能进队\n");
}
if (deQueue(q,e)==0)
printf("队空,不能出队\n");
else
printf("出队一个元素%c\n",e);
DestroyQueue(q);
return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MaxSize 5
typedef char ElemType;

typedef struct queue {
    ElemType *data;
    int front;
    int rear;
    int max_size;
}SqQueue;

void init_queue(SqQueue* q, int max_size)
{
    q->front = q->rear = 0;
    q->data = NULL;
    q->data = (ElemType *)malloc(max_size * sizeof(ElemType));
    if (q->data)
        printf("queue create successfully!\n");
}

int full_queue(SqQueue* q)
{
    return (q->front == (q->rear + 1) % q->max_size) ? 1 : 0;
}

int empty_queue(SqQueue* q)
{
    return (q->front == q->rear) ? 1 : 0;
}

int enqueue(SqQueue* q, int val)
{
    if (full_queue(q))
        return 0;
    else
    {
        q->data[q->rear] = val;
        q->rear = (q->rear + 1) % q->max_size;
    }
    return 1;
}

int dequeue(SqQueue* q)
{
    if (empty_queue(q))
        return 0;
    else
    {
        printf("%d is dequeue\n", q->data[q->front]);
        q->front = (q->front + 1) % q->max_size;
    }
    return 1;
}


void destroy_queue(SqQueue* q)
{
    if (q != NULL)
    {
        free(q->data);
        q->front = q->rear = 0;
    }
}

void print_queue(SqQueue* q)
{
    int i;
    if (empty_queue(q)) {
        printf("queue is empty\n");
        return;
    }
    else {
        for (i = q->front; i < q->rear; i++)
            printf("queue data is %d\n", q->data[i]);
    }
    return;
}

int main()
{
    int i, num;
    queue Q;
    init_queue(&Q, 100);
    for (i = 0; i < 3; i++)
    {
        printf("please input a number:");
        scanf("%d", &num);
        printf("\n");
        if (enqueue(&Q, num) != 0)
            printf("入队成功!\n");
    }
    printf("\n当前队列:\n");
    print_queue(&Q);
    printf("\n");
    dequeue(&Q);
    printf("出队一个元素后的队列:\n");
    print_queue(&Q);

    destroy_queue(&Q);
    printf("\n 清空后的队列:\n");
    print_queue(&Q);
    return 0;
}