JavaScript 汉诺塔

JavaScript 汉诺塔

首页休闲益智Tower of Hanoi 汉诺塔更新时间:2024-07-25

<html> <body> <script type="text/javascript"> document.write("汉诺塔</br>") function hanoi(n,A,B,C) { if(n==1) { document.write("把1号盘子从" A "移到" C "</br>"); count ; } else { hanoi(n-1,A,C,B); document.write("把" n "号盘子从" A "移到" C "</br>"); count ; hanoi(n-1,B,A,C); } } var count=0; var n=4; var A="A"; var B="B"; var C="C"; hanoi(n,A,B,C); document.write("共 " count " 次</br>"); </script> </body> </html>

查看全文
大家还看了
也许喜欢
更多游戏

Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved