josphe.cpp

来自「josphe算法的实现,包含一个头文件」· C++ 代码 · 共 47 行

CPP
47
字号
// jo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "josphe.h"
extern  josphe* phead;
extern  josphe* ptail;
extern  int ncount;


int main(int argc, char* argv[])
{
	 
      ncount=0;
	josphe* p;
	int remain,count=0;
	for(int i=1;i<=10;i++)
	{
		p=new josphe;
		p->add(i);
		ncount++;
	}
	cout<<"原来的号码:";
	phead->list_all();
	cout<<endl;
	remain=ncount;
	p=phead;
	while(remain>2)
	{
		while(count<2)
		{
			count++;
		    p=p->next;
			
		}
		remain--;
		count=0;
		p=p->del();
	}
	cout<<"剩下的号码:";
	phead=p;
	p->list_all();
	cout<<endl;
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?