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

📄 hanio.java

📁 没什么用的程序,希望大家喜欢 我是编程菜鸟哦,
💻 JAVA
字号:

public class Hanio 
{ 
	public static int count;
	public static void Demo(String from,String spare,String to,int n)
	{
		if(n==1)
			{
			System.out.println("disk1"+"\t"+from+"\t"+"-->"+"\t"+to);
			count++;
			}
		else
		{
			Demo(from,to,spare,n-1);
			System.out.println("disk"+n+"\t"+from+"\t"+"-->"+"\t"+to);
			count++;
			Demo(spare,from,to,n-1);
		}	
	}
	public static void main(String[] args)
	{
		System.out.println("Please enter the number of disks.");
		int diskn=3;
		diskn=SavitchIn.readLineInt();
		String from,to,spare;
		from="I";
		spare="II";
		to="III";
		Demo(from,spare,to,diskn);
		System.out.println("You should take at least "+count+" steps.");
		
	}
}

⌨️ 快捷键说明

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