Tower of Hanoi recursive thinking

Tower of Hanoi:
Problem Description: ABC three columns (Note: the source, other, dest), the disc from a stack of plates A of (N) to the C drive, can only move a plate, and the plate must be small to ensure platter above,
N = the AC. 1
N = 2 the BC AB the AC
N = CB the AC. 3 the AC AB BA the BC the AC
...
N .. N = number plates: 1, 2, 3 ....... N
here to use two functions:

public static void move(int n, int source, int dest) 
将第N个盘子从source移到dest

move(n - 1, source, other);//三个盘子空下来的作为other
将N-1个盘子从source移到other

Guess you like

Origin blog.51cto.com/14232658/2441974