/***************************************************************/
/* Die Türme von Hanoi Lizenz: GPL */
/* */
/* (c) 2003 Roland Illig <1illig@informatik.uni-hamburg.de> */
/***************************************************************/
#include <stdio.h>
/**
* Bewegt n Scheiben von Turm a nach Turm c und benutzt als Zwi-
* schenspeicher Turm b.
*/
static void bewege (char a, char b, char c, int n)
{
if (n == 1) {
printf("Lege die oberste Scheibe von Turm %c "
"auf Turm %c.\n", a, c);
} else {
bewege(a, c, b, n-1);
bewege(a, b, c, 1);
bewege(b, a, c, n-1);
}
}
int main (int argc, char **argv)
{
bewege('a', 'b', 'c', 5);
return 0;
}
|