0
#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();
 }

Edited by Nick Evan: n/a

6
Contributors
5
Replies
16
Views
11 Years
Discussion Span
Last Post by yash00yash
0

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.

0

i am still in confusion in TOH recursive function how line number 13 and 15 executes both of them executes concurrently or what??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.