Skip to content

Instantly share code, notes, and snippets.

@ryoppippi
Last active October 12, 2015 11:54
Show Gist options
  • Save ryoppippi/236998296b0fa86057ab to your computer and use it in GitHub Desktop.
Save ryoppippi/236998296b0fa86057ab to your computer and use it in GitHub Desktop.
昨日ハノイの塔が解けなくて本読んだら再帰という概念に出くわした。あまりにも強力でくらっとした。漸化式をそのままかけてしまう。美しい。そしてこれがそのコード。 #課題 #coding #c #CodePiece
void func1(int n,int from, int to,int work,FILE *fq){
if (n>0) {
func1(n-1,from,work,to,fq);
fprintf(fq,"%d %d %d\n",n, from, to );
func1(n-1,work,to,from,fq);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment