#include<iostream> #include<string.h> #include<ctype.h> #include<malloc.h> #include<limits.h> #include<stdio.h> #include<stdlib.h> //#include<io.h> #include<math.h> //#include<process.h> #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 using namespace std; typedef int QElemType; typedef int Status; typedef struct QNode { QElemType data; QNode *next; }*QueuePtr; struct LinkQueue { QueuePtr front,rear; }; void InitQueue(LinkQueue &Q) { if(!(Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode)))) exit(OVERFLOW); Q.front->next=NULL; } void EnQueue(LinkQueue &Q,QElemType e) { QueuePtr p; if(!(p=(QueuePtr)malloc(sizeof(QNode)))) exit(OVERFLOW); p->data=e; p->next=NULL; Q.rear->next=p; Q.rear=p; } Status DeQueue(LinkQueue &Q,QElemType &e) { QueuePtr p; if(Q.front==Q.rear) return ERROR; p=Q.front->next; e=p->data; Q.front->next=p->next; if(Q.rear==p) Q.rear=Q.front; free(p); return OK; } int main() { int i; QElemType d; LinkQueue q; InitQueue(q); while(scanf("%d",&i)!=EOF) { EnQueue(q,i); } while(q.front!=q.rear) {DeQueue(q,d); printf("%d",d);} }