Created
March 12, 2009 10:13
-
-
Save anshumanatri/77994 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Tower of Hanoi | |
//No of calls made for n disks is equal to pow(2,n) -1. | |
void hanoi(int n, char a, char c, char b) | |
{ | |
if(n==1) | |
{ | |
printf("\nShift disk 1 from %c to %c",a,c); | |
return ; | |
} | |
hanoi(n-1,a,b,c); | |
printf("\nShift disk %d from %c to %c" ,n,a,c); | |
hanoi(n-1,b,c,a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment