版权声明:转载请注明原文地址即可,要是本文对您有些许帮助的话,请您在下方点个赞,谢谢啦ヾ(o◕∀◕)ノヾ https://blog.csdn.net/qq_33583069/article/details/89731416
#include <stdio.h>
void move(char x,char y){
printf("%c-->%c\n",x,y);
}
void hanoi(int n,char one,char two,char three){
if(n==1)move(one,three);
else{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
int main()
{
int m,u;
printf("input the number of diskes:");
u=scanf("%d",&m);
if(!u){printf("输入不正确");return 0;}
printf("The step to move %d diskes:",m);
hanoi(m,'A','B','C');
return 0;
}