#include<iostream.h>
#include<stdio.h>
#include<malloc.h>
#define OVERFLOW -2
#define OK 1
#define ERROR 0
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef int ElemType ;
typedef int SElemType;
typedef int Status ;
typedef struct QNode
{
int data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct
{
QueuePtr front;
QueuePtr rear;
}LinkQueue;
status InitQueue(LinkQueue &Q)
{
Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode));
if(!Q.front)cout<<"OVERFLOW";
Q.front.next=NULL;
return OK;
}
status DestroyQueue(LinkQueue &Q)
{
while(Q.front)
{
Q.rear=Q.front.next;
free(Q.front);
Q.front=Q.rear;
}
return OK;
}
void EnQueue(LinkQueue &Q,int e)
{
p=(QueuePtr)malloc(sizeof(QNode));
if(!p)cout<<"OVERFLOW";
p.data=e;
p.next=NULL;
Q.rear.next=p;
Q.rear=p;
}
status DeQueue(LQueue &Q,int &e)
{
if(Q.front==Q.rear) return error;
p=Q.front.next;
e=Q.data;
Q.front.next=p.next;
if(Q.rear==p)Q.rear==Q.front;
free(p);
return OK;
}
}
void main()
{
int x;
LinkQueue qu,q;
for(int i=0;i<5;i++)
{
cin>>x;
EnQueue(qu,x);
}
for(int j=0;j<5;j++)
{
q=DeQueue(qu,x);
cout<<q.data<<" ";
}
}