Пример #1
0
 /// <summary>
 /// Move the specified disk (and all above) from one tower to another tower
 /// </summary>
 /// <param name="disk"></param>
 /// <param name="from"></param>
 /// <param name="to"></param>
 /// <param name="helper"></param>
 private void MoveDisks(int disk, int from, int to, int helper)
 {
     if (disk == 1)
     {
         moves.Enqueue(string.Concat(from + 1, to + 1));  //store move in queue
         return;
     }
     MoveDisks(disk - 1, from, helper, to);
     moves.Enqueue(string.Concat(from + 1, to + 1));     //store move in queue
     MoveDisks(disk - 1, helper, to, from);
 }
Пример #2
0
        static void Split(LineairQueueString queue, string text)
        {
            queue.Enqueue(text.Substring(text.Length - 1));
            if (text.Length == 1)
            {
                return;
            }

            Split(queue, text.Substring(0, text.Length - 1));
        }