#include<stdio.h>#include<stdlib.h>typedefintDatatype;
typedefstructduilienode{
Datatypedata;
structduilienode*next;
}DuilieNode;
typedefstructlastnode{
structduilienode*rear;
}Lastnode;
voidInput(Lastnode*Q,Datatypex)
{
DuilieNode*p=(DuilieNode*)malloc(sizeof(DuilieNode));
p->data=x;p->next=Q->rear->next;
Q->rear->next=p;
Q->rear=p;
}
DatatypeOutput(Lastnode*Q)
{
Datatypex;
DuilieNode*P;
if(Q->rear->next==Q->rear)
printf("队列为空,无法出队");
P=Q->rear->next->next;
x=P->data;
if(P==Q->rear)
{
Q->rear=Q->rear->next;Q->rear->next=P->next;
}
elseQ->rear->next=P->next;
returnx;
}