Beispiel #1
0
        private void ctrlBaton_Click(object sender, EventArgs e)
        {
            if (Numbers != null && Numbers.Length != 0)
              {
            LoTVQueue Queue = new LoTVQueue();
            for (int i = 0; i < Numbers.Length; i++)
              Queue.InQueue(Numbers[i]);
            try
            {
              if (ctrlTxb.Text != "")
              {
            Queue = Thing.CutQueue(int.Parse(ctrlTxb.Text), Queue);

            int Count = Queue.count;
            ctrlDGV.RowCount = Count;
            ctrlDGV.Columns[0].Width = 30;
            for (int i = 0; i < Count; i++)
              ctrlDGV.Rows[i].Cells[0].Value = Queue.OutQueue();
              }
              else
            MessageBox.Show("Пустое окно элемента");
            }
            catch
            {
              MessageBox.Show("Введено неверное число.", "Ошибка");
            }
              }
        }
Beispiel #2
0
        public static LoTVQueue CutQueue(int SacredValue, LoTVQueue OldQueue)
        {
            LoTVQueue NewQueue = new LoTVQueue();

              if (!OldQueue.QueueIsEmpty())
              {
            NewQueue.InQueue(OldQueue.OutQueue());
            do
            {
              if (NewQueue.QueueTail.NodeQueueValue != SacredValue)
            NewQueue.InQueue(OldQueue.OutQueue());
              else
              {
            if (!OldQueue.QueueIsEmpty() && NewQueue.QueueTail.NodeQueueValue == SacredValue && OldQueue.QueueHead.NodeQueueValue == SacredValue)
              NewQueue.InQueue(OldQueue.OutQueue());
            else
              OldQueue.OutQueue();
            if (!OldQueue.QueueIsEmpty())
              NewQueue.InQueue(OldQueue.OutQueue());
              }
            }
            while (!OldQueue.QueueIsEmpty());
              }
              return NewQueue;
        }