Ejemplo n.º 1
0
        public void Pop()
        {
            ForQueue temp;

            while (head != null)
            {
                temp = head;
                head = head.next;
                temp = null;
            }
        }
Ejemplo n.º 2
0
 public void AddinQueue(int a)//положить элемент в очередь
 {
     if (head == null)
     {
         head = new ForQueue(a);
         tail = head;
     }
     else
     {
         ForQueue temp = new ForQueue(a);
         tail.next = temp;
         tail      = temp;
     }
 }
Ejemplo n.º 3
0
 public void FirstDel()
 {
     try
     {
         Console.WriteLine("Извлеченный первый элемент: " + head.data);
         if (head == tail)
         {
             tail = null;
         }
         head = head.next;
         Console.WriteLine("Сама очередь: " + display());
     }
     catch (Exception ex)
     {
         Console.WriteLine("Ошибка: " + ex.Message);
     }
 }
Ejemplo n.º 4
0
        public int searchmin()
        {
            int      min  = head.data;
            ForQueue temp = head;

            while (true)
            {
                if (min > temp.data)
                {
                    min = temp.data;
                }
                if (temp == tail)
                {
                    break;
                }
                temp = temp.next;
            }
            return(min);
        }
Ejemplo n.º 5
0
        public string display()
        {
            string str = "";

            if (head != null)
            {
                ForQueue temp = head;
                while (true)
                {
                    str = str + temp.data + " ";
                    if (temp == tail)
                    {
                        break;
                    }
                    temp = temp.next;
                }
            }
            return(str);
        }
Ejemplo n.º 6
0
        public int count()
        {
            int      i    = 0;
            ForQueue temp = head;

            if (head != null)
            {
                while (true)
                {
                    i++;
                    if (temp == tail)
                    {
                        break;
                    }
                    temp = temp.next;
                }
            }
            return(i);
        }
Ejemplo n.º 7
0
        public int searchmax()
        {
            int      max  = head.data;
            ForQueue temp = head;

            while (true)
            {
                if (max < temp.data)
                {
                    max = temp.data;
                }
                if (temp == tail)
                {
                    break;
                }
                temp = temp.next;
            }
            return(max);
        }
Ejemplo n.º 8
0
 public MQueue()
 {
     head = null;
     tail = null;
 }
Ejemplo n.º 9
0
 public ForQueue(int a)
 {
     data = a;
     next = null;
 }