汉诺塔php模拟输出

 1 function move($n, $from, $to, $with){
 2     if($n == 1){
 3         printf('%d: %s  => %s <br/>', $n, $from, $to);
 4     } else {
 5         move($n - 1, $from, $with, $to);
 6         printf('%d: %s  => %s <br/>', $n, $from, $to);
 7         move($n - 1, $with, $to, $from);
 8     }
 9 }
10 move(8, 'A', 'B', 'T');

 

posted on 2019-05-21 15:01  Jacky Yu  阅读(212)  评论(0编辑  收藏  举报