⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 josphe.h

📁 josphe算法的实现,包含一个头文件
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -