Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void toh(int n,char s,char d ,char t)
- {
- if(n==1)
- {
- printf("MOVE DISK %d From %c to %c\n",n,s,d);
- }
- else
- {
- toh(n-1,s,t,d);
- printf("MOVE DISK %d From %c to %c\n",n,s,d);
- toh(n-1,t,d,s);
- }
- }
- int main(void)
- {
- printf("Enter the Number Of Disks to move\n");
- int n;
- scanf("%d",&n);
- toh(n,'S','D','T');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment