汉诺塔问题
2018-01-30 16:28
246 查看
#include <stdio.h>
#include <conio.h>
int main(){
void hanoi(int n,char one,char two,char three);
int m;
printf("输入层数");
scanf("%d",&m);
printf("移动%d层的步骤为:\n",m);
hanoi(m,'A','B','C');
getch();
}
void hanoi(int n,char one,char two,char three){
void move(char x,char y);
if(n==1)
move(one ,two);
else{
hanoi(n-1,one,two,three);
move(one,three);
hanoi(n-1,two,one,three);
}
}
void move(char x,char y){
printf("%c-->%c\n",x,y);
}
#include <conio.h>
int main(){
void hanoi(int n,char one,char two,char three);
int m;
printf("输入层数");
scanf("%d",&m);
printf("移动%d层的步骤为:\n",m);
hanoi(m,'A','B','C');
getch();
}
void hanoi(int n,char one,char two,char three){
void move(char x,char y);
if(n==1)
move(one ,two);
else{
hanoi(n-1,one,two,three);
move(one,three);
hanoi(n-1,two,one,three);
}
}
void move(char x,char y){
printf("%c-->%c\n",x,y);
}
相关文章推荐
- 汉诺塔问题
- Java递归求解汉诺塔问题
- 汉诺塔问题 Java实现
- PKU《程序设计》专项课程_递归汉诺塔问题
- 经典问题之汉诺塔
- 数据结构(java语言描述)递归实现——汉诺塔问题
- 汉诺塔问题(+递推公式)
- 汉诺塔问题
- OpenJ_Bailian - 4147-汉诺塔问题(Hanoi)
- 汉诺塔问题的递归解法
- 汉诺塔的问题
- 汉诺塔问题的python递归实现
- 纠结了好久才弄得明白一点点的汉诺塔问题,现在把一些方程与大家分享一下!
- 学习C/C++语言:递归求解hanoi汉诺塔问题
- JAVA: 用java实现汉诺塔问题
- 汉诺塔问题1
- 汉诺塔问题求解
- 【蓝桥杯-递归优化】汉诺塔问题的优化
- 汉诺塔问题
- python实现汉诺塔问题