标签:
#include<stdio.h>
void hanoi(int n,char A,char B,char C)
{
if(n==1)
printf("%c-->%c\n",A,C);
else
{
hanoi(n-1,A,C,B);
printf("%c-->%c\n",A,C);
hanoi(n-1,B,A,C);
}
}
int main()
{
int n;
scanf("%d",&n);
hanoi(n,‘A‘,‘B‘,‘C‘);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/lldsidi/p/5650900.html