예제 #1
0
        public int Pop()
        {
            SNode runner = Top;

            while (runner.Next.Next != null)
            {
                runner = runner.Next;
            }
            SNode retVal = runner.Next;

            runner.Next = runner.Next.Next;
            return(retVal.Value);
        }
예제 #2
0
 public void Add(int val)
 {
     if (Top == null)
     {
         Top = new SNode(val);
     }
     else
     {
         SNode runner = Top;
         while (runner.Next != null)
         {
             runner = runner.Next;
         }
         runner.Next = new SNode(val);
     }
 }
예제 #3
0
 public Stacks()
 {
     Top = null;
 }
예제 #4
0
 public SNode(int val)
 {
     Value = val;
     Next  = null;
 }