Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- void moveDisk(char f,char t)
- {
- printf("moving disk from %c to %c\n",f,t);
- }
- void moveTower(int h,char a, char b,char c)
- {
- if(h > 0)
- {
- moveTower(h-1,a,c,b);
- printf("Moving disk from %c to %c\n",a,c);
- moveTower(h-1,b,a,c);
- }
- }
- int main()
- {
- int n,total_move;
- scanf("%d", &n,printf("Enter the Disk numbers: "));
- total_move = pow(2,n)-1;
- printf("Total Move %d\nHere the steps:\n", total_move);
- moveTower(n,'A','B','C');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement