#include<iostream>
using namespace std ;
#include"HanLuoTower.h"
void main()
{
int n;
cout << "Enter the number of discs:";
cin >> n;
char One = 'A';
char Two = 'B';
char Three = 'c';
cout << "The step of Moving n discs from A to C is:"<<endl;
MoveOnetoThree( n, One , Two, Three);
cout << "the Step Number is:" << k<<endl;
}
void MoveOnetoThree(int n, char One ,char Two, char Three)
{
if (1==n)
{
cout<<"Move"<<n<<"from"<<One<<"to"<<Three<<endl;
k++;
}
else
{
MoveOnetoThree(n-1, One, Three, Two);
cout<<"Move"<<n<<"from"<<One<<"to"<<Three<<endl;
k++;
MoveOnetoThree(n-1, Two, One, Three);
}
}
lujin0312
- 粉丝: 3
- 资源: 14
最新资源
- js-leetcode题解之158-read-n-characters-given-read4-ii-call
- js-leetcode题解之157-read-n-characters-given-read4.js
- js-leetcode题解之156-binary-tree-upside-down.js
- js-leetcode题解之155-min-stack.js
- js-leetcode题解之154-find-minimum-in-rotated-sorted-array-ii.js
- js-leetcode题解之153-find-minimum-in-rotated-sorted-array.js
- js-leetcode题解之152-maximum-product-subarray.js
- js-leetcode题解之151-reverse-words-in-a-string.js
- js-leetcode题解之150-evaluate-reverse-polish-notation.js
- js-leetcode题解之149-max-points-on-a-line.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈