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

📄 circularlistapp.cpp

📁 约瑟夫问题
💻 CPP
字号:
//CircularList.cpp文件的实现

#include"random.h"
#include"CircularNode.cpp"
#include<iostream.h>
#include"CircularList.cpp"
#include<string.h>

void main()
{
    int n=0; //本次玩游戏的总人数
    int m=0; //方法一中将要披删除的人的位置
    char ch; 
    char Go;

	RandomNumber rnd; //定义产生随机数的对象
    CircularList<int>S;  //定义循环链表的对象

	cout<<"--------$$$  Welcome To Play With The JosePhus Game  $$$--------"<<endl;
	cout<<"-------- In This Game YOU Can Select Two Ways To  Play  With:"<<endl;
	cout<<"-------- a:The Frist Way"<<endl;
	cout<<"-------- b:The Second Way"<<endl;
	cout<<"-------- y or Y:Go On Playing"<<endl;
	cout<<"-------- Others: Eixt The Game"<<endl; 



	do
	{      
		cout<<"----Input The Number Of Person To Play With The Game--(n):"<<endl;
		cin>>n;
		cout<<"----Input The Position To Be Deleted--(m):"<<endl;
		cin>>m;

	    for(int i=1;i<=n;i++)
		{S.InsertAfter(i,rnd.Random(n+100)+1);} // 创建一个大小为n循环链表
	
         cout<<"----Enter Your chioce--(a) Or (b) Or (others):"<<endl; 
	     cin>>ch ; //获取一个字符
		 cin.get();

		 switch(ch)
		 {
		  case 'a':
				    S.JosePhusFristWay(n,m);
			    	break;
				  
			case 'b':
				
					S.JosePhusSecondWay(n,m);
				    break;
				
			default:
				{cout<<"Your Chioce is wrong!"<<endl;}
		 }
        
		 cout<<"If You Want To Go On Play With This Game, Please Input The character ('Y') OR ('y'):"<<endl;
         cin>>Go;  
         
	}while(Go=='Y'||Go=='y');
	S.Clear(); //清空链表
}

⌨️ 快捷键说明

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