function hanoi(n:number,from:number,to:number):void{
if(n === 1){
console.log(`${from} move to ${to}`)
return
}
let temp = 6 - from - to
hanoi(n - 1, from, temp)
console.log(`${from} move to ${to}`)
hanoi(n - 1, temp, to)
}
汉诺塔
最新推荐文章于 2023-04-19 15:44:12 发布