package com.gxmedu.divide_and_conquer;
/**
* @author 郭学明
* @version 1.0
*/
public class HanoiTower {
public static void main(String[] args) {
hanoi(3,'A','B','C');
}
public static void hanoi(int towerNum,char a,char b,char c){
if(towerNum == 1){
System.out.println("最上面的盘从" + a + "=>" + c);
}else {
hanoi(towerNum - 1,a,c,b);
System.out.println("移动第" + towerNum + "个塔从" + a + "=>" + c);
hanoi(towerNum - 1,b,a,c);
}
}
}