请高手用C语言链表模拟一个队列 谢谢
来源:百度知道 编辑:UC知道 时间:2024/05/31 04:15:08
请高手用C语言链表模拟一个队列
小弟先谢谢了
小弟先谢谢了
#define MAXSIZE 100
typedef int datatype;
typedef struct{
datatype a[MAXSIZE];
int front;
int rear;
}seqqueue;
/*队列置空*/
void initseqqueue(seqqueue *p)
{
p->front=p->rear=0;
}
/*判断队列是否这空*/
int isemptyseqque(seqqueue *p)
{
return(p->front==p->rear?1:0);
}
/*输出队列中的元素*/
void outputseqqueue(seqqueue *p)
{
int i;
if(isemptyseqqueue(p)){printf("\nThe sequece queue is empty\n");exit(1);}
for(i=p->front;i<p->rear;i++)
printf("%5d",p->a[i]);
}
/*取得队列首结点值*/
datatype getfirstseqqueue(seqqueue *p)
{
if(isemptyseqqueue(p)){printf("\nThe sequece queue is empty\n");exit(1);}
return p->a[p->front];
}
/*给队列插入一个结点*/
void insertseqqueue(seqqueue *p)
{
int i;
if(p->rear==MAXSIZE){printf("\nTh