typedefstruct{int front;int rear;int size;int*data;} MyCircularQueue;/** Initialize your data structure here. Set the size of the queue to be k. */
MyCircularQueue*myCircularQueueCreate(int k){
MyCircularQueue *queue=(MyCircularQueue *)malloc(sizeof(MyCircularQueue));
queue->data=(int*)malloc(sizeof(int)*(k+1));
queue->front=0;
queue->rear=0;
queue->size=k+1;return queue;}/** Checks whether the circular queue is empty or not. */
bool myCircularQueueIsEmpty(MyCircularQueue* obj){
bool IsEmpty=false;if(obj->rear==obj->front){
IsEmpty=true;}return IsEmpty;}/** Checks whether the circular queue is full or not. */
bool myCircularQueueIsFull(MyCircularQueue* obj){
bool IsFull=false;if((obj->rear+1)%obj->size==obj->front){
IsFull=true;}return IsFull;}/** Insert an element into the circular queue. Return true if the operation is successful. */
bool myCircularQueueEnQueue(MyCircularQueue* obj,int value){
bool IsFull=myCircularQueueIsFull(obj);if(IsFull){return false;}else{
obj->rear=(obj->rear+1)%obj->size;
obj->data[obj->rear]=value;return true;}}/** Delete an element from the circular queue. Return true if the operation is successful. */
bool myCircularQueueDeQueue(MyCircularQueue* obj){
bool IsEmpty=myCircularQueueIsEmpty(obj);if(IsEmpty){return false;}else{
obj->front=(obj->front+1)%obj->size;return true;}}/** Get the front item from the queue. */intmyCircularQueueFront(MyCircularQueue* obj){
bool IsEmpty=myCircularQueueIsEmpty(obj);if(!IsEmpty){return obj->data[obj->front+1];}else{return-1;}}/** Get the last item from the queue. */intmyCircularQueueRear(MyCircularQueue* obj){
bool IsEmpty=myCircularQueueIsEmpty(obj);if(!IsEmpty){return obj->data[obj->rear];}else{return-1;}}voidmyCircularQueueFree(MyCircularQueue* obj){free(obj);
obj=NULL;}