汉诺塔-递归实现

#include<stdio.h>
void move(char x,char y)
{
	printf("%c->%c
",x,y);
}
//将n个盘子从1中借助2移动到3
void hanoi(int n,char one,char two,char three)
{
	if(n==1)
		move(one,three);
	else
	{
		hanoi(n-1,one,two,three);
		move(one,three);
		hanoi(n-1,two,one,three);

	}
}
int main()
{
	int m;//盘子个数
	scanf("%d",&m);
	hanoi(m,'A','B','C');
	return 0;
}

【推广】 免费学中医,健康全家人
原文地址:https://www.cnblogs.com/zhchoutai/p/8675535.html