/* File: /dolomite/home/kscott/www/sysadmin/integrity/tower.c */ /* Author: K. Scott Rowe */ /* Time-stamp: <02/20/2000 19:21:48 kscott@bendenweir.nmt.edu> */ #include #define DEBUG 1 #define err(x) (printf("%s: x \n", __FUNCTION__)) #define puterr(x,y,z) (printf("%s: x z is y\n", __FUNCTION__, z)) void tower(char from, char to, char aux, int n) { if(n == 1) { printf("MOVE disk 1 from peg %c to peg %c\n", from, to) ; } else { tower(from, aux, to , n - 1) ; printf("Move disk %d from peg %c to peg %c\n", n, from, to) ; tower(aux, to, from, n - 1) ; } } main() { tower('A', 'C', 'B', 3) ; }