text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

c02p108.cpp

Go 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

Generated on Sun Aug 27 11:05:08 2006 for AWLogo by  doxygen 1.4.6