예제 #1
0
        //извлечь из стека
        public int Pop()
        {
            NodeSt p = Head;

            Head = Head.next;
            return(p.state);
        }
예제 #2
0
 //добавить в стек
 public void Push(int x)
 {
     if (Head == null)
     {
         NodeSt p = new NodeSt();
         p.state = x;
         p.next  = Head;
         Head    = p;
     }
     else
     {
         NodeSt p = new NodeSt();
         p.state  = x;
         p.number = Head.number + 1;
         p.next   = Head;
         Head     = p;
     }
 }
예제 #3
0
        public void PushIndex(int index, int token)
        {
            NodeSt temp = Dostup;
            bool   flag = false;

            while (!flag && temp != null)
            {
                if (temp.number == index)
                {
                    flag = true;
                }
                else
                {
                    temp = temp.next;
                }
            }
            if (flag)
            {
                temp.state = token;
            }
        }
예제 #4
0
 public Stack()
 {
     Head = null;
 }
예제 #5
0
 public NodeSt()
 {
     state  = 0;
     number = 0;
     next   = null;
 }