static void Main(string[] args)
{
            Hanoi(
5, 'A', 'B', 'C');
            Console.ReadLine();
        }

       
public static void Hanoi(int n, char A, char B, char C)
        {
           
//汉诺塔问题
           
//将n个盘子从A座借助B座,移到C座
            if (n == 1) Move(A, C);
           
else
            {
                Hanoi(n
- 1, A, C, B);
                Move(A, C);
                Hanoi(n
- 1, B, A, C);
            }

        }

       
public static void Move(char startPlace, char endPlace)
        {
            Console.WriteLine(
"Move {0} To {1}", startPlace, endPlace);
        }

posted on 2011-08-18 11:05  qqhfeng16  阅读(486)  评论(0编辑  收藏  举报