package 递归
;
public class 汉诺塔
{
public static void main(String
[] args
) {
test01(5,"A","B","C");
}
public static void test01(int N
,String from
, String to
,String help
){
if (N
== 1){
System
.out
.println("move"+N
+"from"+from
+"to"+to
);
}else {
test01(N
-1,from
,help
,to
);
System
.out
.println("move"+N
+"from"+from
+"to"+to
);
test01(N
-1,help
,to
,from
);
}
}
}
转载请注明原文地址:https://blackberry.8miu.com/read-39870.html