汉洛塔算法

   private void MoveItem(int n,string source,string useHandle,string target)
    {
        if (n == 1)
        {
            Response.Write(source + "----->" + target+"<br>");
        }
        else
        {
            MoveItem(n - 1, source, target, useHandle);
            Response.Write(source + "----->" + target+"<br>");
            MoveItem(n - 1, useHandle, source, target);
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        MoveItem(5, "source", "useHandle", "target");

    }

你可能感兴趣的:(算法)