#include <stdio.h>
#define MaxSize 10
typedef struct Queue{
    int data[MaxSize];
    int head,tail;
}Queue;

void InitQueue(Queue &S){
    S.head=0;
    S.tail=0;
}

bool QueueOverflow(Queue S){
    if((S.tail+1) % MaxSize==S.head){printf("overflow\n");return true;}
    return false;
}

bool QueueEmpty(Queue S){
if(S.head==S.tail){return true;}
return false;
}

bool QueuePush(Queue &S,int e){
    if(QueueOverflow(S)){printf("overflow\n");return false;}
    S.data[S.tail]=e;S.tail=(S.tail+1)%MaxSize;
    return true;
}

bool QueuePop(Queue &S,int *x){
    if(QueueEmpty(S)){printf("empty\n");return false;}
    *x=S.data[S.head];
    S.head=(S.head+1)%MaxSize;
    return true;
    
}

int main(){
    Queue Q;
    InitQueue(Q);
    QueuePush(Q,100);
    QueuePush(Q,99);
    int x;
    QueuePop(Q,&x);
    printf("%d\n",x);
    QueuePop(Q,&x);
    printf("%d\n",x);
    return 0;
}