#include <iostream>
using namespace std;
void hano(int n, char from, char temp, char to)
{
if (n==1)
cout << from << "=>" << to <<endl;
else
{
hano(n-1, from, temp, to);
hano(1, from, to, temp);
hano(n-1, temp, to, from);
}
}
int main()
{
hano( 3,'A', 'B', 'C');
return 0;
}
递归汉诺塔问题
最新推荐文章于 2023-09-26 21:16:36 发布