📄 biandao.cpp
字号:
// biandao.cpp: implementation of the biandao class.
//
//////////////////////////////////////////////////////////////////////
#include "biandao.h"
#include <stdlib.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
biandao::biandao( )
{
front=rear=NULL;
}
void biandao::Enbiandao(int x)
{
Node *s;
s=new Node;
s->data=x; //申请一个数据域为x的结点s
s->next=NULL;
if(front==NULL)//空队列,新结点既是队头,又是队尾
{
front=rear=s;
}
else
{ rear->next=s; //将结点s插入到队尾
rear=s;
}
}
int biandao::Debiandao()
{
Node *p;
int x;
if (front==NULL) throw "便道空";
p=front;
x=p->data; //暂存队头元素
front=front->next; //将队头元素所在结点摘链
if (front==NULL)
rear=front; //判断出队前队列长度是否为1
delete p;
return x;
}
bool biandao::Empty()
{
if (front==NULL)
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -