汉诺塔算法
public class Main {
public static void main(String[] args) {
hanoi(4,'A','B','C');
}
//将n个盘子从a经过b搬运到c上
private static void hanoi(int n, char a, char b , char c){
if ( n == 1)
System.out.println(a + " -> " + c);
else
{
hanoi(n-1,a,c,b);
hanoi(1,a,b,c);
hanoi(n-1,b,a,c);
}
}
}