/*
汉若塔问题
*/
#define
N 3
main()
{
hanoi(N,
'
A
'
,
'
B
'
,
'
C
'
);
getch();
}
hanoi(
int
n,
char
A,
char
B,
char
C)
{
if
(n
==
1
)
{
printf(
"
move %d from %c to %c\n
"
,n,A,C);
}
else
{
hanoi(n
-
1
,A,C,B);
printf(
"
move %d from %c to %c\n
"
,n,A,C);
hanoi(n
-
1
,B,A,C);
}
}