栈(stack) LIFO last in first out
队列(queue) FIFO first in first out
只有队尾指针的队列
int rear=-1;if(rear==MAX-1){printf("上溢");return;}rear++;data[rear]=x;}
有队头和队尾的队列
int front=-1,rear=-1;if(rear==MAX-1){printf("上溢");return;}rear++;data[rear]=x;}
循环队列
int front=-1,rear=-1;if((rear+1)%MAX==front){printf("上溢");return;}rear=(rear+1)%MAX//rear++;data[rear]=x;}
网友评论