C++ Programming Tutorial

 
 
 
 

Image

 # include <iostream.h>
 # include    <conio.h>

 void move(const int n,const int fromTower,
                    const int toTower,const int spareTower)
 {
    if(n>0)
    {
       move((n-1),fromTower,spareTower,toTower);

       cout<<\"\\t Move the Top Disk from Tower-\"<<fromTower
                          <<\" to Tower-\"<<toTower<<\"\\n\";

       move((n-1),spareTower,toTower,fromTower);
    }
 }

 int main( )
 {
    clrscr( );

    cout<<\"\\n\\t **************   TOWERS OF HANOI   **************\\n\"<<endl;
    cout<<\"\\t The Mystery of Towers of Hanoi is as follows : \\n\"<<endl;

    move(4,1,3,2);

    cout<<\"\\n\\t *************************************************\";

    getch( );
    return 0;
 }

    Related Post:
  1. Program to draw a K-Curve of nth order

  2. Program of swapping numbers by call by reference

  3. Program of inline function

  4. Program of Shortest Path for Given Source and Destination (using Dijkstras Algo.)

  5. Program to show the implementation of Sutherland-Hodgeman Polygon Clipping Algorithm

  6. Program to draw a line using Bresenhams Line Algorithm (BLA) for lines with slopes positive and less than 1

  7. Program to implement a Translator that reads an Infix Expression translates it into a Postfix Expression and evaluate the Postfix Expression

  8. Program to illustrate the use of call-by-refrence method using pointers

  9. Program to calculate anybody\’s single digit lucky number

  10. Program of Sutherland Hodgemann Algorithm for Polygon clipping

  11. Program to illustrate the implementation of X-Direction Shear Transformation

  12. Program to find largest integer among the three and display it using function with no return type

  13. Program that computes and display the square of first ten integers. (using for loop)

  14. Program to show the implementation of Binary Search Tree as Sets

  15. Program to show the implementation of None-or-All String Clipping Strategy (Text Clipping Example)

  16. Program that performs addition of 2 matrix using friend function

  17. Program to find the day of a week of a given date from 15 october 1582 to end of universe using arrays

  18. Program to illustrate the implementation of 3D Rotation Transformation along x-axis

  19. Program to illustrate unary operator(decrement operator) overloading with return type

  20. Program to illustrate the implementation of linked list as a Queue

 
 
Didn't find what you were looking for? Find more on Program to solve the Towers of Hanoi Problem (using Recursive Algorithm)