help in tower if hanoi

Hi

how to code the function move(int source int destination) in tower of hanoi
thnx

Comments

  • Search Google on 'Tower of Hanoi C++'. First hit gave me a complete example code! Hopefully this will end you session of 'Tower of Hanoi' questions

    See ya,
    bilderbikkel

  • : Search Google on 'Tower of Hanoi C++'. First hit gave me a complete example code! Hopefully this will end you session of 'Tower of Hanoi' questions
    :
    : See ya,
    : bilderbikkel
    :
    :

    Hello,
    yes, for detailed explaination of the logic search 'Tower of Hanoi' in google. I have written appropriate code below(using recursive function)
    [code]
    #include
    void hanoi(int n, char src, char aux, char dest)
    {
    if (0 == n)
    return;
    hanoi(n-1 , src, dest, aux);
    cout << n << "th moved from " << src << " to " << dest;
    hanoi(n-1, aux, src, dest);
    }

    main()
    {
    int n;
    cout<< "Please enter no. of disc of hanoi tower :"
    cin << n;
    hanoi (n, 'a', 'b', 'c');
    }
    [/code]

    I hope this is helpful
    Thx
    Dipalee
  • : : Search Google on 'Tower of Hanoi C++'. First hit gave me a complete example code! Hopefully this will end you session of 'Tower of Hanoi' questions
    : :
    : : See ya,
    : : bilderbikkel
    : :
    : :
    :
    : Hello,
    : yes, for detailed explaination of the logic search 'Tower of Hanoi' in google. I have written appropriate code below(using recursive function)
    : [code]
    : #include
    : void hanoi(int n, char src, char aux, char dest)
    : {
    : if (0 == n)
    : return;
    : hanoi(n-1 , src, dest, aux);
    : cout << n << "th moved from " << src << " to " << dest;
    : hanoi(n-1, aux, src, dest);
    : }
    :
    : main()
    : {
    : int n;
    : cout<< "Please enter no. of disc of hanoi tower :"
    : cin << n;
    : hanoi (n, 'a', 'b', 'c');
    : }
    : [/code]
    :
    : I hope this is helpful
    : Thx
    : Dipalee
    :
    Hi Dipalee
    thnx
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories