Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Convert this code to c++ #include static int count=0; void toh(int p, char from, char to, char a) { if(p==0) return; if (p == 1)
Convert this code to c++
#include static int count=0; void toh(int p, char from, char to, char a) { if(p==0) return; if (p == 1) { printf(" 1: %c to %c",from,to); count++; return; } toh(p-1,from,a,to); printf(" %d: %c to %c",p,from,to); count++; toh(p-1,a,to,from); } int main() { int n; printf("How many disks:"); scanf("%d",&n); toh(n,'A','B','C'); printf(" Total moves:%d",count); return 0; }
----------------------------
to
c++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started