汉诺塔问题
关键码:<!--
var n,x,y,z;
function move(n,x,y,z)
{
if(n==1)
{
document.write(x+ "-->" + z + "<br>");
}
else
{
move(n-1,x,z,y);
document.write(x+ "-->" + z + "<br>");
move(n-1,y,x,z);
}
}
function main()
{
var h;
h=parseInt(prompt("\ninput number:"));
document.write("the step to moving " + h + " diskes:<br>");
move(h,"A","B","C");
}
main();
//-->
写 4个 disk的程序运行过程分析,关键是move函数,如第一步move(4,'A','B','C');move(3,'A','C','B');move(2,'A','B','C');move(1,'A','C','B');输出A-->B,后面就不知道了,请各位帮忙了,小弟新手,谢了哦!