白猪掌柜的
public class Main { public static void hanoi(int n, String from, String to, String using) { if (n == 1) { move(from, using); } else { hanoi(n - 1, from, using, to); move(from, using); hanoi(n - 1, to, from, using); } } private static void move(String from, String target) { System.out.println("move:" + from + "-->" + target); } public static void main(String[] args) { System.out.println("移动汉诺塔的步骤:"); hanoi(3, "1", "2", "3"); }}