//使用顺序表实现循环队列的入队和出队
#include<iostream>
using namespace std;
const int MAX_SIZE = 100;
typedef struct Queue
{
int q[MAX_SIZE];
int front;
int rear;
}*Queue;
void enqueue(Queue &Q,int x)
{
if((Q->rear+1)%MAX_SIZE==Q->front)cout<<"队列上溢出"<<endl;
else
{
Q->rear=(Q->rear+1)%MAX_SIZE;
Q->q[Q->rear]=x;
}
}
void delqueue(Queue &Q)
{
if((Q->front+1)%MAX_SIZE==Q->rear) cout<<"栈空"<<endl;
else
{
Q->front=(Q->front+1)%MAX_SIZE;
}
}
//使用顺序表实现循环队列的入队和出队
最新推荐文章于 2021-12-20 11:37:29 发布