l need help to do this programm
please help me
l need help to do this programm
please help me
I have never heard of such a variant of the problem, but if you want help, refer to our homework policy.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
However many poles you have (and do double check the number), the basic process is the same, to play the puzzle:
1) Call one pole the "answer" pole.
2) Call the pole with the rings now, the "source" pole.
3) Anything else is an auxillary pole ("aux").
Then unload source rings to the aux poles, until no more rings can be handled. Then move the next ring (the largest you have access to at that time), to an empty aux pole. Now using the source pole as temporary storage, move all the rings from the other aux and answer pole, to the aux pole, in proper order by size. The answer pole will serve as temporary storage, for now. Later, the source pole will replace the answer pole as temporary storage once it is empty.
So what you're doing is recreating the original stack of rings, but on the aux pole, not the source pole (and not the answer pole, either).
Keep doing this until you have all but the largest ring from the source pole, stacked up on one of the aux poles. Now move the largest ring from the source pole to the answer pole. Last, use the now empty source pole as an aux pole, to shift all the other rings from their stack on the aux pole, to the answer pole, by repeating this step (make a new stack, then move the largest unordered ring from the aux or source pole, to the answer pole).
If you play the game several times, you'll see the pattern. If you can't find a game with 4 poles, and that's what's needed, I recommend you make your own out of either paper rings you cut out with scissors, or some washers of different sizes. A few straws might serve as the poles, when stuck into a little holder (like maybe a plastic cup lid?).
It's a beautiful example of a recursive program, but I would NOT call it trivial.