汉诺塔
来源:互联网 发布:淘宝客服犯错奖罚制度 编辑:程序博客网 时间:2024/06/16 08:25
汉诺塔
void move(char x,char y){cout<<x<<"-->"<<y<<endl;}void hanoi(int n,char one,char two,char three)//将 n 个盘从 one 座借助 two 座,移到 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;
cout<<"input the number of diskes:";
cin>>m;
cout<<"The steps of moving "<<m<<" disks:"<<endl;
hanoi(m,'A','B','C');
return 0;
}
0 0
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 汉诺塔
- 浅析java中的Class类及其对象
- 大端、小端、魔数等概念
- 深度学习(十四)基于CNN的性别、年龄识别
- java开发第一个JNI示例程序(基于linux操作系统)--java调用native方法
- Activity与fragment之间数据传递方法
- 汉诺塔
- 在C#中怎样利用句柄发送消息
- nginx简易教程
- 深度学习(十五)基于级联卷积神经网络的人脸特征点定位-CVPR 2013
- opencv中setMousecallback的用法
- 安卓apk 反编译
- 高度封装FMDB框架:各用一句代码更新(添加&修改),查询,删除用户信息
- stopPropagation, preventDefault 和 return false 的区别
- 服务器基础:IO多路复用之select、poll、epoll详解