汉诺塔
来源:互联网 发布:淘宝登陆不了 编辑:程序博客网 时间:2024/06/17 22:28
输入n表示盘子的个数,只能小的在上,大的在下,求将第一个移到第三个的
最小步移法。
#include <stdio.h>int main(){ void hanoi(int n,char one,char two,char three); // 对hanoi函数的声明 int m; printf("input the number of diskes:"); scanf("%d",&m); printf("The step to move %d diskes:\n",m); hanoi(m,'A','B','C');}void hanoi(int n,char one,char two,char three) // 定义hanoi函数 // 将n个盘从one座借助two座,移到three座 { void move(char x,char y); // 对move函数的声明 if(n==1) move(one,three); else { hanoi(n-1,one,three,two); move(one,three); hanoi(n-1,two,one,three); } } void move(char x,char y) // 定义move函数 { printf("%c-->%c\n",x,y); }
最小步移法。
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 最让心潮澎湃的品牌--云桌
- 双机热备+负载均衡 线上方案 (Heartbeat+DRBD+NFS+Keepalived+Lnmp)
- Five Minds for the Future: Mental Building Blocks for the New Century
- python嵌入到C++时发布的流程
- VC里的集合类、链表类、映射类
- 汉诺塔
- NSdata 与 NSString,Byte数组,UIImage 的相互转换
- nessus离线下载plugin
- Keepalived双机热备
- n边形面积
- 第6课 使用下拉列表、微调按钮
- oral topics
- NSDate,NSString相互转换,解决八小时间隔问题
- Sublime Text 2