Hanoi

来源:互联网 发布:淘宝产品拍摄方案 编辑:程序博客网 时间:2024/06/02 01:14

public class Hanoi {

public static void main(String[] args) {    hanoi(10,'a','b','c');}private static void hanoi(int n,char src,char support,char dest) {    if (n == 1) {        System.out.println(src + "-->" + dest);    }else{        hanoi(n - 1, src, dest, support);        System.out.println(src + "-->" + dest);        hanoi(n - 1,support,src,dest);    }}

}

原创粉丝点击