#include<iostream>
using namespace std;
int main()
{
void hanoi(int n,char one,char two,char three);
int num;
cout<<"请输入要计算的盘子数:";
cin>>num;
hanoi(num,‘A‘,‘B‘,‘C‘);
}
void hanoi(int n,char one,char two,char three)
{
void move(char x,char y);
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)
{
cout<<x<<"-->"<<y<<endl;
}汉诺塔问题的递归实现
原文:http://blog.csdn.net/christprince007/article/details/39577881