Description
建立队列的顺序存储结构,进行入队和出队的操作,并输出队列中的数据元素。
Input
多组输入,每组输入为两行,第一行输入一个整数,为输入数据的个数,第二行输入要输入的数据(整数).
Output
每行输出是队列里面的数据元素。
Sample Input
5
1 2 3 4 5
3
12 3 90
Sample Output
1 2 3 4 5
12 3 90
//队列的输入输出操作
#include <bits/stdc++.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
//#define OVERFLOW 0
typedef int Status;
typedef int Boolean;
typedef int ElemType;
using namespace std;
typedef struct QNode
{
ElemType 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));
Q.front->next=NULL;
return OK;
}
Status DestoryQueue(LinkQueue &Q)
{
while (Q.front)
{
Q.rear=Q.front->next;