#include<stdio.h>
int a=0;
int main(){
void oppo(int i,char one,char two,char three);
int n;
scanf("%d",&n);
oppo(n,'A','B','C');
return 0;
}
void oppo(int i,char one,char two,char three){
void move(int x,int y);
if(i==1){
move(one,three);
}
else{
oppo(i-1,one,three,two);
move(one,three);
oppo(i-1,two,one,three);
}
}
void move(int x,int y){
a++;
printf("%c-->%c\n",x,y);
}
汉诺塔问题
最新推荐文章于 2024-07-12 16:34:36 发布