Exemple #1
0
        public lib(double val)
        {
            Vuzol n = new Vuzol(val);

            head = n;
            tail = n;
        }
Exemple #2
0
        public void DelAfterMax() // функція видалення чисел, після максимального
        {
            Vuzol Max = head.FindMax(head);

            Max.next = null;
            tail     = Max;
        }
Exemple #3
0
        private double FindAverage() // функція пошуку середнього значення
        {
            double average = 0;
            int    count   = 0;
            Vuzol  current = head;

            while (current != null)
            {
                average += current.val;
                current  = current.next;
                count   += 1;
            }
            average = average / count;
            return(average);
        }
Exemple #4
0
 public Vuzol FindMax(Vuzol max)
 {
     if (val > max.val)
     {
         max = this;
     }
     if (next == null)
     {
         return(max);
     }
     else
     {
         return(next.FindMax(max));
     }
 }
Exemple #5
0
        public double[] FillArray()
        {
            int   count   = 0;
            Vuzol current = head;

            while (current != null)
            {
                current = current.next;
                count  += 1;
            }
            current = head;
            double[] valarray = new double[count];
            for (int i = 0; i < count; i++)
            {
                valarray[i] = current.val;
                current     = current.next;
            }
            return(valarray);
        }
Exemple #6
0
        public void DelBelowAverage() //функція видалення чисел, які менші за середнє значення
        {
            double average = FindAverage();
            Vuzol  current = head;

            while (current != null)
            {
                if (current.val < average)
                {
                    current.Delete();
                    if (tail == current)
                    {
                        tail = current.prev;
                    }
                    if (head == current)
                    {
                        head = current.next;
                    }
                }
                current = current.next;
            }
        }
Exemple #7
0
        public void NewHead(double val)
        {
            Vuzol newVuzol = head.NewPrev(val);

            head = newVuzol;
        }
Exemple #8
0
 public Vuzol NewPrev(double value)
 {
     prev = new Vuzol(value, this);
     return(prev);
 }
Exemple #9
0
 public Vuzol(double inVal, Vuzol inNext = null, Vuzol inPrev = null)
 {
     val  = inVal;
     next = inNext;
     prev = inPrev;
 }