![]() |
Data Abstraction and Problem Solving with C++Walls and Mirrorsby Frank M. Carrano |
![]() |
c02p108.cppGo to the documentation of this file.00001 00027 void solveTowers(int count, char source, char destination, 00028 char spare) 00029 { 00030 if (count == 1) 00031 { cout << " Move top disk from pole " << source 00032 << " to pole " << destination << endl; 00033 } 00034 else 00035 { solveTowers(count-1, source, spare, destination); // X 00036 solveTowers(1, source, destination, spare); // Y 00037 solveTowers(count-1, spare, destination, source); // Z 00038 } // end if 00039 } // end solveTowers |