Created
May 8, 2014 05:54
-
-
Save kimitoboku/63d2960efd2cf5e402dc to your computer and use it in GitHub Desktop.
hanoi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void hanoi(int n,char a,char b,char c){ | |
if(n>0){ | |
hanoi(n-1,a,b,c); | |
printf("一番上を%cから%cに移動\n",a,b); | |
hanoi(n-1,b,c,a); | |
} | |
} | |
int main(void){ | |
int n; | |
printf("何段の塔を行うか入力して下さい:"); | |
scanf("%d",&n); | |
hanoi(n,'A','B','C'); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment