Пример #1
0
            public static void AddNodeA(IntNode a, int x)
            {
                bool flag = true;

                while (a.GetNext() != null)
                {
                    if (x > a.GetInfo() && x <= a.GetNext().GetInfo())
                    {
                        IntNode c = new IntNode(x, a.GetNext());
                        a.SetNext(c);
                        a    = c;
                        flag = false;
                    }
                    else if (x <= a.GetInfo() && flag)
                    {
                        IntNode c = new IntNode(a.GetInfo(), a.GetNext());
                        a.SetInfo(x);
                        a.SetNext(c);
                        flag = false;
                    }
                    a = a.GetNext();
                }
                if (x > a.GetInfo() && flag)
                {
                    IntNode p = new IntNode(x);
                    a.SetNext(p);
                }
            }
Пример #2
0
            public static IntNode DelNode(IntNode pos)// function for delete a organ in the list
            {
                IntNode a = pos.GetNext();

                pos.SetNext(pos.GetNext().GetNext());
                a.SetNext(null);
                return(a);
            }
Пример #3
0
            public static int LenNode(IntNode allList)// this function return the length node
            {
                int count = 0;

                while (allList.GetNext() != null)
                {
                    allList = allList.GetNext();
                    count++;
                }
                return(count);
            }
Пример #4
0
 public static int LenNodeR(IntNode allList)// this Recursive function return the length node
 {
     if (allList.GetNext() == null)
     {
         return(0);
     }
     else
     {
         allList = allList.GetNext();
         return(1 + LenNodeR(allList));
     }
 }
Пример #5
0
            public static IntNode AddNode(IntNode pos, int a)//function for add a organ in to the list
            {
                IntNode c = new IntNode(a, pos.GetNext());

                pos.SetNext(c);
                return(pos);
            }