You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
548 B

# 汉偌塔问题
* **问题分析**
* 1、把`n-1`个圆盘从A经过C移动到B
* 2、把第`n`个圆盘从A移动到C
* 3、把`n-1`个圆盘从B经过A移动到C
* **原理**
* 代码
```java
public static void main(String[] args) {
run(3, "A", "B", "C");
}
private static void run(Integer n, String a, String b, String c) {
if (n>0) {
run(n-1, a, c, b);
System.out.println("从【"+a+"】移动到【"+c+"】");
run(n-1, b, a, c);
}
}
```
```go
```