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

📄 c1.cpp

📁 实现集合的交和并集
💻 CPP
字号:
#include<iostream.h>
#include"c1.h"
template<class Type>void CircList<Type>::Insert(const Type& value)
{
	Type x;
	cout<<"Enter the password:"<<endl;
	cin>>x;
	if(current==NULL)
		current=first=new CircListNode<Type>(value, x, first);
	else
	{
		CircListNode<Type>*temp=current; 
		current=new CircListNode<Type>(value,x,current->link);
		temp->link=current;
		current=current->link;
	}
}
template<class Type>void CircList<Type>::Remove()
{
	if(current!=NULL)
	{
		CircListNode<Type>* temp=current;
		current=current->link;
		delete temp;
		if(current==first)
			if(first->link==first)
				current=NULL;
			else current=current->link;
	}
}
template<class Type>void CircList<Type>::Josephus(int n,int m)
{
	Firster();
	for(int i=0;i<n-1;i++)
	{
		for(int j=0;j<m-1;j++) Next();
		cout<<"Delete person"<<GetData1()<<endl;
		m=GetData2();
		Remove();
	}
}
void main()
{
	CircList<int> c;
	int n,m;
	cout<<"Enter the Number of Contestants:"<<endl;
	cin>>n>>m;
	for(int i=1;i<=n;i++) c.Insert(i);
		c.Josephus(n,m);
}

⌨️ 快捷键说明

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