经典递归算法研究:hanoi塔的理解与实现

关于hanoi塔的原理以及概念,请Google,访问不了去百度。

主要设计到C中程序设计中递归的实现;

主代码实现如下:

void hanoi(int src, int dest, int tmp, int n)
{
    if(n == 1)
    {
        move(src, dest);
        return;
    }
    
    hanoi(src, tmp, dest, n-1);
    move(src, dest);
    hanoi(tmp, dest, src, n-1);
}

全部实现代码见Github: https://github.com/huaixzk/hanoi

当每天的朝阳洒在我们的脸上,我们要拿什么 来证明自己在这个城市的存在??
原文地址:https://www.cnblogs.com/crazymod/p/3801216.html