Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Edit following code to count tge number of times the disks move replace \"HELP\"

ID: 3534948 • Letter: E

Question

Edit following code to count tge number of times the disks move replace "HELP" in main:

void moveDisks(int n, char fromTower,

char toTower, char auxTower){

if (n==1)

cout << "Move disk " << n <<" from " << fromTower << " to " << toTower << endl;

else

{

moveDisks(n - 1, fromTower, auxTower, toTower);

cout << "move disk " << n << " from " << fromTower << " to " << toTower << endl;

moveDisks(n -1, auxTower, toTower, fromTower);

}

}

int main(){

cout << "Enter number of disks: ";

int n;

cin >> n;

cout <<"the moves are: " << endl;

moveDisks(n, 'A', 'B', 'C');


cout << "It took "<< HELP <<" moves to move "<< n <<" disks";

return 0;

}

Explanation / Answer

I could do it two ways after having an eye at your problem. I have stored the solutions here.



http://www.shrib.com/IgAG8shU


Dont forget to rate.


Cheers!!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote