http://mambo.kuhp.kyoto-u.ac.jp/~masahiro/c/indexj.html
http://mambo.kuhp.kyoto-u.ac.jp/~masahiro/c/euc/hanoi.c

#include <stdio.h>
#define MAX 256

void hanoi(int n, int from, int to, int use);

main()
{
int n;
char tmp[MAX];

do{
printf("ハノイの塔の円盤の枚数は何枚ですか?1以上の整数で答えて下さい。> ");
fgets(tmp, MAX, stdin);
tmp[MAX - 1] = 0;
n = atoi(tmp);
/* scanf("%d",&n); */
}while(n < 1);
hanoi(n, 1, 2, 3);
}
void hanoi(int n, int from, int to, int use)
{
if(n <= 0) return;
hanoi(n - 1, from, use, to);
printf("円盤%dを棒%dから棒%dに動かす。\n", n, from, to);
hanoi(n - 1, use, to, from);
}