关于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

 posted on 2014-06-21 17:38  huaixiaoz  阅读(743)  评论(0编辑  收藏  举报