You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// There are three towers (A,B,C) and one of the towers has some numbers of discs of different sizes. The problem is to transfer all the disks from tower A to tower C, one disk at a time and a larger disk can not sit on top of any smaller disk.
void TOH(int n, int A, int B, int C) { // n is number of disks
if (n > 0)
{
TOH(n - 1, A, C, B);
cout << "A disk was moved from " << A << " to "<< C << endl;