static void Main() { AdtStack<int> stack = new AdtStack<int>(); for (int i = 0; i < 10; i++) { stack.Push(i); Console.WriteLine("Push: [{0}]", i); } for (int i = 0; i < 10; i++) { var current = stack.Pop(); Console.WriteLine("Pop: [{0}]", current); } }
static void Main(string[] args) { //Implement the ADT stack as auto - resizable array. //Resize the capacity on demand(when no space is available to add / insert a new element). Console.WriteLine("Create ADT stack with size 2"); var myStack = new AdtStack<int>(2); Console.WriteLine("Add 1, 2, 3"); myStack.Push(1); myStack.Push(2); myStack.Push(3); Console.WriteLine("ADT stack size now is {0}", myStack.Size); Console.WriteLine("Stack elements: "); Console.WriteLine(myStack.Pop()); Console.WriteLine(myStack.Pop()); Console.WriteLine(myStack.Pop()); }
public static void Main() { /* Implement the ADT stack as auto-resizable array. Resize the capacity on demand (when no space is available to add / insert a new element). */ var adtStack = new AdtStack<int>(); adtStack.Push(100); adtStack.Push(20); adtStack.Push(600); adtStack.Push(10); adtStack.Push(69); adtStack.Push(14); adtStack.Push(235); adtStack.Push(4); adtStack.Push(67); adtStack.Push(88); adtStack.Push(99); adtStack.Push(8); Console.WriteLine("The elements in the stack is: {0}", adtStack.Count); Console.WriteLine("The last element: {0}", adtStack.Pop()); }