首页 > 其他 > 详细

队列的入队和出队操作

时间:2015-08-03 21:00:31      阅读:194      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<conio.h>
using namespace std;


typedef struct student{
int data;
struct student *next;
}node;
typedef struct linkqueue
{
node *first, *rear;
}queue;


//队列的入队
queue *insert(queue *HQ, int x)
{
node *s;
s = (node*)malloc(sizeof(node));
s->data = x;
s->next = NULL;
if (HQ->rear == NULL)
{
HQ->first = s;
HQ->rear = s;
}
else
{
HQ->rear->next = s;
HQ->rear = s;
}
}
//队列出队
queue *del(queue *HQ)
{
node *p;
int x;
if (HQ->first == NULL)
{
printf("\n yichu");
}
else
{
x = HQ->first->data;
p = HQ->first;
if (HQ->first == HQ->rear)
{
HQ->first = NULL;
HQ->rear = NULL;
}
else
{
HQ->first = HQ->first->next;
free(p);
}
return (HQ);
}
}





版权声明:本文为博主原创文章,未经博主允许不得转载。

队列的入队和出队操作

原文:http://blog.csdn.net/wangfengfan1/article/details/47261427

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!