Source of solveTowers.cpp


  1: //  Created by Frank M. Carrano and Tim Henry.
  2: //  Copyright (c) 2013 __Pearson Education__. All rights reserved.

  4: void solveTowers(int count, char source, char destination, char spare)
  5: {
  6:    if (count == 1)
  7:    {
  8:       cout << "Move top disk from pole " << source
  9:            << " to pole " << destination << endl;
 10:    }
 11:    else
 12:    {
 13:       solveTowers(count - 1, source, spare, destination); // X
 14:       solveTowers(1, source, destination, spare);         // Y
 15:       solveTowers(count - 1, spare, destination, source); // Z
 16:    }  // end if
 17: }  // end solveTowers