Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Tower of Hanoi c#

static void Move( int discs, Stack<int> fromPeg,  Stack<int> toPeg, Stack<int> otherPeg)
{
    if (discs == 0)
    {
        return;
    }

    Move(discs - 1, fromPeg, otherPeg, toPeg);

    toPeg.Push(fromPeg.Pop());

    Move(discs -1, otherPeg, toPeg, fromPeg);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Tower #Hanoi
ADD COMMENT
Topic
Name
6+4 =