Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!