1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // FileName : hanoi.c
4 // Version : 0.10
5 // Author : Ryan Han
6 // Date : 2013/07/01 10:55:30
7 // Comment :
8 //
9 ///////////////////////////////////////////////////////////////////////////////
10 #include <stdio.h>
11 static void move(const char x, const int n, const char z)
12 {
13 printf("Move planet %d from pole %c to %c \n", n, x, z);
14 }
15
16 static void hanoi(const int n, const char x, const char y, const char z)
17 {
18 if(1 == n)
19 move(x, 1, z);
20 else
21 {
22 hanoi(n-1, x, z, y);
23 move(x, n, z);
24 hanoi(n-1, y, x, z);
25 }
26 }
27
28 int main()
29 {
30 hanoi(4, 'X', 'Y', 'Z');
31 }