Hanoi问题
#include<stdio.h>
int main()
{
int m;
void hanoi(int n,char x,char y,char z);
printf("input the number of disk:\n");
scanf("%d",&m);
hanoi(m,'A','B','C');
return 0;
}
void hanoi(int n,char x,char y,char z)
{
void move(char a,char b);
if(n==1)
move(x,z);
else
{
hanoi(n-1,x,z,y);
move(x,z);
hanoi(n-1,y,x,z);
}
}
void move(char a,char b)
{
printf("%c----->%c\n",a,b);
}
Hanoi问题的更多相关文章
- Hanoi问题java解法
用什么语言解法都差不多,思路都是一样,递归,这其中只要注重于开始和结果的状态就可以了,对于中间过程,并不需要深究.(我细细思考了一下,还是算了.=_=) 代码其实很简单注重的是思路. 问题描述:有一个 ...
- HDU1329 Hanoi Tower Troubles Again!——S.B.S.
Hanoi Tower Troubles Again! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- ZOJ-1239 Hanoi Tower Troubles Again!
链接:ZOJ1239 Hanoi Tower Troubles Again! Description People stopped moving discs from peg to peg after ...
- The Towers of Hanoi Revisited---(多柱汉诺塔)
Description You all must know the puzzle named "The Towers of Hanoi". The puzzle has three ...
- Hanoi塔
2016-03-19 17:01:35 问题描述: 假设有三个命名为 A B C 的塔座 ,在塔座A上插有n个直径大小不相同,由小到大编号为1 ,2 ,3 ,··· ,n的圆盘,要求将A座上的圆盘移至 ...
- [CareerCup] 3.4 Towers of Hanoi 汉诺塔
3.4 In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes ...
- 栈应用hanoi
/* 课本p54页*/ #include<stdio.h> #include <iostream> using namespace std; void move(int n, ...
- 【数据结构】hanoi
#include<stdio.h> void hanoi(int n,char x,char y,char z) { ; ) printf("%d. Move disk %d f ...
- 算法训练 Hanoi问题
算法训练 Hanoi问题 时间限制:1.0s 内存限制:512.0MB 问题描述 如果将课本上的Hanoi塔问题稍做修改:仍然是给定N只盘子,3根柱子,但是允许每次最多移动相邻的 ...
随机推荐
- MOOCULUS微积分-2: 数列与级数学习笔记 7. Taylor series
此课程(MOOCULUS-2 "Sequences and Series")由Ohio State University于2014年在Coursera平台讲授. PDF格式教材下载 ...
- FZU 2184 逆序数还原
传送门 Description 有一段时间Eric对逆序数充满了兴趣,于是他开始求解许多数列的逆序数(对于由1...n构成的一种排列数组a,逆序数即为满足i<j,ai>aj的数字对数),但 ...
- django写的留言板
代码见 https://github.com/linux-wang/show-me-the-code/tree/master/dj_test 实际上是 https://github.com/linux ...
- jboss wildfly 外网访问
在standalone.xml中: 找到下面三行,看到是要访问public(8080端口的)和management的interface,将interface中的127.0.0.1改为0.0.0.0即可 ...
- POJMatrix(二维树状数组)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 22058 Accepted: 8219 Descripti ...
- JS-用js的for循环实现九九乘法表以及其他算数题等
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>f ...
- 常用机器视觉工具----图像分析工具(blob分析)
http://blog.sina.com.cn/s/blog_67cc4eb70100ivnt.html Blob分析:Blob分析目的在于对图像中的2-D形状进行检测和分析,得到诸如目标位置.形状. ...
- SSH(Struts Spring Hibernate开发框架)
Spring(Model) Spring的核心思想是IoC和AOP,Spring使得管理对象更加方便,极大的降低组件之间的耦合度,实现了软件各层之间的解耦. Struts(View) 使用Struts ...
- Oracle开发常用函数
max 最大数 自动加 1 create or replace function fun_getmaxlot( vend in varchar2 , domain IN VARCHAR2, tag i ...
- ubuntu下JDK的安装
硬盘上有下载好的JDK,直接解压后配置profile环境变量就行 export JAVA_HOME=/usr/lib/jvm/java-8-oracle export JRE_HOME=${JAVA_ ...