josphe.h
来自「josphe算法的实现,包含一个头文件」· C头文件 代码 · 共 80 行
H
80 行
#include "iostream.h"
#define NULL 0
int ncount;
class josphe
{
public:
int data;
josphe* next;
josphe* prior;
josphe(){data=0;next=NULL;prior=NULL;}
josphe(int n);
josphe(josphe &p);//
~josphe(){}
void add(int i);
josphe* del();
void list_all();
};
josphe* phead;
josphe* ptail;
josphe::josphe(josphe &p)
{
data=p.data;
next=p.next;
prior=p.prior;
}
josphe::josphe(int i)
{
data=i;next=NULL;prior=NULL;
}
void josphe::add(int i)
{
if(!phead)
{
this->data=i;
this->next=this;
this->prior=this;
phead=this;
ptail=this;
}
else
{
this->data=i;
ptail->next=this;
phead->prior=this;
this->prior=ptail;
this->next=phead;
ptail=this;
}
}
josphe* josphe::del()
{
josphe* p;
josphe* q;
this->prior->next=this->next;
this->next->prior=this->prior;
p=this;
q=this->next;
delete p;
ncount--;
return q;
}
void josphe::list_all()
{
josphe* p;
p=phead;
for(int i=1;i<=ncount;i++)
{
cout<<" "<<p->data;
p=p->next;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?