-->
当前位置:首页 > 题库

PROGRAMMING:Non recursive implementation of Hanoi Tower

Luz5年前 (2021-05-10)题库453
With the help of stack, the problem of Hanoi Tower (n, a, B, c) is solved in a non recursive (cyclic) way, that is, n plates are moved from the starting column (marked as "a") to the target column (marked as "C") by means of the column (marked as "B"), and each movement meets the requirements of Hanoi Tower problem.
###Input format:
Enter a positive integer n, that is, the number of disks on the starting column.
###Output format:
Each operation (move) occupies one line and is output in the format of column 1 to column 2.
###Input example:
```in
three
```
###Output example:
```out
a -> c
a -> b
c -> b
a -> c
b -> a
b -> c
a -> c
```






answer:If there is no answer, please comment