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);
}