限制条件 大的不能在小的上面
using System;
namespace DivideAndConquer
{
class Program
{
static int count = 0;
static void Main(string[] args)
{
Solve(2);
Console.WriteLine(count);
Console.ReadKey();
}
static void Solve(int n)
{
Hannouta(n, "第一个柱子", "第二个柱子", "第三个柱子");
}
static void Hannouta(int n,string a,string b,string c)
{
if (n == 1)
{
Show(n, a, c);
}
else
{
Hannouta(n - 1, a, c, b);
Show(n, a, c);
Hannouta(n - 1, b, a, c);
}
count++;
}
static void Show(int i,string a,string b)
{
Console.WriteLine("第"+i+"圆盘"+"从'"+a+"'移动到:'"+b+"'");
Console.WriteLine();
}
}
}