链队
#include<stdio.h>
#include<malloc.h>
typedef int elemtype;
typedef struct Qnode{
elemtype data;
struct Qnode *next;
}Qnode, *Queuep;
typedef struct {
Queuep front;
Queuep rear;
}linkqueue;
int init(linkqueue &Q){
Q.front = Q.rear = (Queuep)malloc(sizeof(Qnode)) ;
if(!Q.front) return 0;
Q.front->next = NULL;
return 1;
}
int enter(linkqueue &Q,int e){
Qnode *s;
s=(Queuep)malloc(sizeof(Qnode));
s->data =e;
s->next=NULL;
Q.rear ->next=s;
Q.rear =s;
return 1;
}
int out(linkqueue &Q,int e){
Queuep p;
if( Q.front == Q.rear ) return 0;
p=Q.front ->next;e=p->data ;
Q.front->next=Q.front ->next->next;
if(Q.rear == p) Q.rear = Q. front;
free(p);
return 1;
}