public class Hano {
private int n;
public Hano(int n) {
this.n = n;
}
public void start() {
move(n, 'A', 'B', 'C');
}
//将盘子从from移到help
/*public static void move(int n, char from, char help, char to){
if(n == 1){
System.out.println(from + "---->" + help);
}else {
move(n-1, from,to,help);
System.out.println(from + "---->" + help);
move(n-1,to,help,from);
}
}*/
//将盘子从from移到to
public static void move(int n, char from, char help, char to){
if(n == 1){
System.out.println(from + "---->" + to);
}else {
move(n-1, from,to,help);
System.out.println(from + "---->" + to);
move(n-1,help,from,to);
}
}
}