You do not really want to see the code. It is just about 10 lines, with 2 recursive calls inside.
The first recursive call would move all but the lowest disk on an auxilary one, and then move the biggest of them to the final destination. As you do it, you again have two towers to mave around your disks, because if you put any disk on top of the biggest, it does not break the rule.
The second recursive call, makes the first one to solve the problem for n - 1 disks, and at the end of it, it will move the pre-biggest disk on top of the biggest in the 3rd tower. Totally, it will happen n time, making the problem smaller each time, until n becomes 1, which is to mave the last disk on top of all in the 3rd tower.
template <class Q>
void Hanoi(n,T Start, T Auxilary, T End)
{
if (n != 0)
{
Hanoi((n-1),Start,End,Auxilary);
Move(Start,End);
Hanoi((n-1),Auxilary,Start,End);
}
}
// That's it
Best Regards,
aphrodita@mail.krovatka.ru {uiuc rules}