C数组模拟实现栈和队列
#define MaxSize 1000 //定义栈 typedef struct Stack { char data[MaxSize];//数组实现栈内元素定位 int top;//栈顶下标 int buttom;//栈底下标 } Stack;
#define MaxSize 1000 //定义队列 typedef struct Queue { char data[MaxSize]; int front; int rear; int count; } Queue;
//入队列 bool inQueue(Queue *queue,char element) { if(queue->count >= MaxSize){ return false }else{ queue->rear = (queue->rear + 1) % MaxSize; queue->data[queue->rear] = element; queue->count++; return true; } }