标签:
public class HanoiTower { public static void main(String[] args)throws Exception { hanoiTower(64,"X","Y","Z"); } public static void hanoiTower(int n, String x, String y, String z) { if(n == 1) { System.out.println(x+"-->"+z); return; } else { hanoiTower(n-1,x,z,y); System.out.println(x+"-->"+z); hanoiTower(n-1,y,x,z); } } }
标签:
原文地址:http://www.cnblogs.com/kuillldan/p/5701441.html