#include<stdio.h>
int count=0;
void move(int n,char a,char b)
{
count++;
printf("第%d次:把%d层从%c->%c\n",count,n,a,b);
}
void hanoi(int n,char a,char b ,char c)
{
if(n==1)
{
move(n,a,c);
}
else
{
hanoi(n-1,a,c,b);
move(n,a,c);
hanoi(n-1,b,a,c);
}
}
int main()
{
int n;
char a,b,c;
printf("请输入汉诺塔的城数\n");
scanf("%d",&n);
hanoi(n,'a','b','c');
return 0;
}