Chinaunix首页 | 论坛 | 博客

OS

  • 博客访问: 2220534
  • 博文数量: 691
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2660
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-05 12:49
个人简介

不浮躁

文章分类

全部博文(691)

文章存档

2019年(1)

2017年(12)

2016年(99)

2015年(207)

2014年(372)

分类: C/C++

2014-12-09 21:45:45

#include
#include
typedef int datatype;
typedef struct _node_
{
 datatype data;
 struct _node_ *next;
} linknode, *linklist;
typedef struct
{
 linklist front;
 linklist rear;
} linkqueue;
linkqueue *CreateEmptyQueue()
{
 linkqueue *lq;
 lq = (linkqueue *)malloc(sizeof(linkqueue));
 lq->front = lq->rear = (linklist)malloc(sizeof(linknode));
 lq->front->next = NULL;
 return lq;
}
int EmptyQueue(linkqueue *lq)
{
 return (lq->front == lq->rear);
}
void EnQueue(linkqueue *lq, datatype x)
{
 lq->rear->next = (linklist)malloc(sizeof(linknode));
 lq->rear = lq->rear->next;
 lq->rear->data = x;
 lq->rear->next = NULL;
 return;
}
datatype DeQueue(linkqueue *lq)
{
 linklist q;
 q = lq->front;
 lq->front = q->next;
 free(q);
 return (lq->front->data);
}
void ClearQueue(linkqueue *lq)
{
 linklist q;
 while (lq->front != lq->rear)
 {
  q = lq->front;
  lq->front = q->next;
  free(q);
 }
 return;
}

阅读(903) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~