Hey, I have a recursive fxn that happens to be the algorithm for the Tower of Hanoi. I need to count how many times it makes a move, but I do not know where to add the simple code of move++ or something of that nature. If you could help me that would be great. Thanks. Here is the code:
Code:void Move(int n, char source, char destination, char spare) { if (n == 1) { cout << "Move the top disk from " << source << " to " << destination << endl; } else { Move (n - 1, source, spare, destination); Move (1, source, destination, spare); Move (n - 1, spare, destination, source); } }



LinkBack URL
About LinkBacks


