入隊演算法
linklist in_queue(linklist rear,datatype x)
{
s=new lnode;
s->data=x;
s->next=rear->next;
rear->next=s;
rear=s;
return(rear );
}
出隊演算法
linklist out_queue(linklist rear,datatype *x)
if (rear->next==rear)
return(NULL);
q=rear->next->next;
if (q==rear)
rear=rear->next;
rear->next=rear;
else
rear->next->next=q->next;
*x=q->data;
delete q;
return(rear);
入隊演算法
linklist in_queue(linklist rear,datatype x)
{
s=new lnode;
s->data=x;
s->next=rear->next;
rear->next=s;
rear=s;
return(rear );
}
出隊演算法
linklist out_queue(linklist rear,datatype *x)
{
if (rear->next==rear)
return(NULL);
q=rear->next->next;
if (q==rear)
{
rear=rear->next;
rear->next=rear;
}
else
{
rear->next->next=q->next;
}
*x=q->data;
delete q;
return(rear);
}