Program to solve the Towers of Hanoi Problem (using Recursive Algorithm) in C++ Programming

# include 
# include

void move(constint n,constint fromTower,constint toTower,constint spareTower)
{
if(n>0)
{
move((n-1),fromTower,spareTower,toTower);
cout<<"\t Move the Top Disk from Tower-"<<<" to Tower-"<<<"\n";
move((n-1),spareTower,toTower,fromTower);
}
}
int main( )
{
clrscr( );
cout<<"\n\t ************** TOWERS OF HANOI **************\n"<<<"\t The Mystery of Towers of Hanoi is as follows : \n"<<<"\n\t *************************************************";
getch( );
return 0;
}

No comments:

Post a Comment