标签:
#include<stdio.h>
void move(char x,char y)
{
printf("%c->%c\n",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;
}版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/u012701023/article/details/46778483