# JAVA 递归 汉诺塔+阶乘

1.汉诺塔

package qq;

public class hannuota {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int nDisks = 3;
System.out.println("1111");
moveDish(nDisks, 'A', 'B', 'C');
}

public static void moveDish(int level, char from, char inter, char to) {
System.out.println(level);
if (level == 1) {
System.out.println("2222");
System.out.println("从" + from + "移动盘子1号到" + to);
} else {
System.out.println("33333");
moveDish(level - 1, from, to, inter);
System.out.println("从" + from + "移动盘子" + level + "号到" + to);
moveDish(level - 1, inter, from, to);
}
}
}


package qq;

public class hannuotayk {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int nDisks = 3;
moveDish(nDisks, 'A', 'B', 'C');
}
public static void moveDish(int level, char a, char b, char c) {
if (level>0) {

moveDish(level - 1, a, c, b);
System.out.println("从" + a + "移动盘子" + level + "号到" + c);
moveDish(level - 1, b, a, c);

}
}
}


2.阶乘

举报原因： 您举报文章：JAVA 递归 汉诺塔+阶乘 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)