[求助]汉诺塔程序的执行步骤?
Console.WriteLine("**************************************************************"); Console.WriteLine("***** ****");
Console.WriteLine("******** put a on b with c **********");
Console.WriteLine("*************** *********************");
Console.WriteLine("**************************************************************");
Console.WriteLine("请输入盘的个数N:");
string a=Console.ReadLine();
int i;
if(a.Length>0)
{
i=int.Parse(a);
HNT(i,"a","b","c");
}
}
public static void HNT(int i,string a,string b,string c)
{
if(i>0)
{
HNT(i-1,a,c,b); //当i=1时,执行完当前递归调用后i=0,但再次递归调用后i=1,为什么?
Console.WriteLine("将"+a+"放到"+b+"上");
HNT(i-1,c,b,a);
}