#include <iostream>
#include <iomanip>
using namespace std;
void TowersOfHanoi(int , int , int , int );
int main( int argc, char *argv[] )
{
TowersOfHanoi(3,1,3,2); ///non-recursive call
return 0;
}
void TowersOfHanoi(int disks, int sourcePeg, int destinationPeg, int tempPeg )
{
if( disks == 1 )
{
cout << sourcePeg << " --> " << destinationPeg << endl;
return;
}
TowersOfHanoi( disks - 1, sourcePeg, tempPeg, destinationPeg );//recursive call
cout << sourcePeg << " --> " << destinationPeg << endl;
TowersOfHanoi(disks-1,tempPeg,destinationPeg, sourcePeg );//recursive call
}
Please some body explain to me how this code function.


