Sunday, July 8, 2007

Write C code to solve the Tower of Hanoi problem.

Here is an example C program to solve the Tower Of Hanoi problem...


main()
{
towers_of_hanio(n,'L','R','C');
}

towers_of_hanio(int n, char from, char to, char temp)
{
if(n > 0)
{
tower_of_hanio(n-1, from, temp, to);
printf("\nMove disk %d from %c to %c\n", n, from, to);
tower_of_hanio(n-1, temp, to, from);
}
}

3 comments:

NuraArun said...

Super :)

Anonymous said...

It's awesome to visit this website and reading the views of all mates concerning this post, while I am also keen of getting experience.

Here is my page - Bmr calculator

Mobile App Development Company in Delhi said...

Thank you very nice sharing.