Hanoi function
#define MOVE(x,y) \
printf("Move disk from "\
%c to %c.\n", (x), (y))
void hanoi(char A, char B, char C, int n)
{
if (n == 1) {
MOVE(A, B);
return;
}
hanoi(A, C, B, n-1);
MOVE(A, B);
hanoi(C, B, A, n-1);
}
This is the program
pg200.c
Previous slide
Next slide
Back to first slide
View graphic version