汉诺塔的递归性
public class Hanoi {
public void hanoi(int n,char origin, char assist,char destination){
if(n==1){
move(origin,destination);
}else{
hanoi(n-1,origin,destination,assist);
move(origin,destination);
hanoi(n-1,assist,origin,destination);
}
}
//Print the route of the movement
private void move(char origin,char destination){
System.out.println("Direction:"+origin+"--->"+destination);
}
public s......
阅读全文