队列的输入输出操作

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;
   
  • 4
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值