示例#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 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);
            }
示例#3
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);
            }