Hanoi塔

```


public class Hanoi {

public static void moveOne(char from, char to) {

System.out.println(from + "->" + to);

}

public static void move(char from, char to, char aux, int n) {

if (n == 1) {

moveOne(from, to);

return;

}

move(from, aux, to, n - 1);

moveOne(from, to);

move(aux, to, from, n - 1);

}

public static void main(String[] args) {

int n = 1000;

move('A', 'B', 'C', n);

}

}

```

你可能感兴趣的:(Hanoi塔)