1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public class { public static void (int n){ if(n > 0) { fun(n, ”LEFT”, ”MID”, ”RIGHT”); } } public static void fun(int n, String from, String mid, String to) { if(n == 1) { System.out.println(“move from ” + from + ” to ” + to); } else { fun(n-1, from, to, mid); fun(1, from, mid, to); fun(n-1, mid, from, to); } } }
|
近期评论