#include"stdio.h"
struct qnode
{
int data;
struct qnode *next;
};
typedef struct
{
struct qnode *front ,*rear;
}linkqueue;
void initqueue(linkqueue *q)
{
q->front =(struct qnode *)malloc(sizeof(struct qnode));
q->rear=q->front ;
q->front->next=NULL;
}
void enqueue(linkqueue *q,int x)
{
struct qnode *s;
s=(struct qnode*)malloc(sizeof(struct qnode));
s->data=x;
s->next=NULL;
q->rear->next=s;
q->rear=s;
}
int delqueue(linkqueue *q)
{ struct qnode *p;
if(q->front==q->rear)
printf("the queue is empty!\n");
else
{
p=q->front;
q->front=q->front->next;
free(p);
return (q->front->data);
}
}
main()
{
linkqueue *qq;
char a[]={"i love you"},i;
char b[11];
initqueue(qq);
for(i=0;i<11;i++)
enqueue(qq,a[i]);
for(i=0;i<11;i++)
{b[i]=delqueue(qq);
printf("%c",b[i]);
}
}