• 微信公众号：美女很有趣。 工作之余，放松一下，关注即送10G+美女照片！

# 链队列的基本操作

1周前 (06-11) 13次浏览

#include<iostream>

//队列的链式表达，队列多用链式表达.

using namespace std;

typedef struct quee
{
int age;

typedef struct
{
}queelist;

void innitialquee(queelist *q)
{
q->front= q ->rear= new quee;
if (q->front)
{
cout << “队列初始化成功” << endl;
q->front = q->rear;
q->front->next = NULL;
return;
}
else
cout << “初始化失败” << endl;
}//链队列初始化

void insertquee(queelist* q, int t)
{

if (!q1)
{
cout << “失败” << endl;
}
else
{
q1->age = t;
q1->next = NULL;
q->rear->next = q1;
q->rear = q1;
}
}//入链队列操作

void outquee(queelist* q)
{
if (q->front == q->rear)
{
cout << “队列为空” << endl;
return;
}
else
if (q->front->next == q->rear->next)
{
cout << “队列只有一个数据” << endl;
cout << q->front->next->age << endl;
q->rear->next = q->front->next=NULL;
return;
}
else
{
cout << q->front->next->age << endl;
q->front = p->next;
free(p);
}
}//出链队的操作

void deletequee(queelist* q)
{

while (q->front != NULL)
{
q->rear = q->front->next;
free(q->front);
q->front = q->rear;
}
}//队列的销毁

int main()
{

queelist* q;
innitialquee(q);
insertquee(q, 3);
outquee(q);
deletequee(q);
return 0;
}