Thursday, June 27, 2013

Write a recursive function for TOH problem.



void transfer (int n, char from, char to, char temp)
  {
     if(n>0)
        {
           transfer(n-1, from, temp, to);
           printf(“\n Move disk %d from %c to %c”, n, from, to);
           transfer(n-1, temp, to, from);
        }
}

No comments:

Post a Comment