Towers of Hanoi(Recursion)

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2005
Posts: 3
Reputation: Chinjoo is an unknown quantity at this point 
Solved Threads: 0
Chinjoo Chinjoo is offline Offline
Newbie Poster

Towers of Hanoi(Recursion)

 
0
  #1
Nov 13th, 2005
#include<stdio.h>
#include<conio.h>
#include<math.h>
void hanoi(int x, char from,char to,char aux)
{

if(x==1)
{
printf("Move Disk From %c to %c\n",from,to);
}
else
{
hanoi(x-1,from,aux,to);
printf("Move Disk From %c to %c\n",from,to);
hanoi(x-1,aux,to,from);
}

}
void main()
{
int disk;
int moves;
clrscr();
printf("Enter the number of disks you want to play with:");
scanf("%d",&disk);
moves=pow(2,disk)-1;
printf("\nThe No of moves required is=%d \n",moves);
hanoi(disk,'A','C','B');
getch();
}
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,823
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 748
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Towers of Hanoi(Recursion)

 
0
  #2
Nov 13th, 2005
Please stop posting poorly formated non-standard code for no reason at all. If you insist on spamming the forum with pointless threads, I'll delete them without hesitation.
New members chased away this month: 3
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,054
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Towers of Hanoi(Recursion)

 
0
  #3
Nov 13th, 2005
If you are so inclined to contribute fully-working code snippets, they would be most appreciated in our code snippet library @ www.daniweb.com/code/ - not the forums.

Thanks!
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1
Reputation: raftinga is an unknown quantity at this point 
Solved Threads: 0
raftinga raftinga is offline Offline
Newbie Poster
 
0
  #4
Dec 18th, 2008
thanks for the program ...its g8 with few errors which can b corrected easily
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: Towers of Hanoi(Recursion)

 
0
  #5
Dec 24th, 2008
If you full code in correct format you can add in the code snippets rather posting on the forum
Thanks!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC