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.
Dont forget to rate.
Cheers!!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.