static void Main(string[] args) { var stack = new MyStack <string>(); stack.Push("ivane"); Console.WriteLine(stack.Peek()); Console.WriteLine(stack.Pop()); stack.Push("Sralo"); stack.Push("me4e"); stack.Push("na"); stack.Push("pute4e"); Console.WriteLine(stack.Count); Console.WriteLine(stack.Pop()); Console.WriteLine(stack.Count); }
static void Main() { MyStack stack = new MyStack(); Console.WriteLine($"Is my stack empty?\n\t{stack.IsEmpty()}"); stack.Push(10); Console.WriteLine($"Is my stack empty?\n\t{stack.IsEmpty()}"); stack.Push(20); stack.Pop(); Console.WriteLine($"Stack size is: {stack.GetSize()}"); Console.WriteLine($"Is my stack full?\n\t{stack.IsFull()}"); stack.Push(30); stack.Push(40); Console.WriteLine($"Is my stack full?\n\t{stack.IsFull()}"); Console.ReadLine(); }
public static void Main() { var stack = new MyStack <int>(); stack.Push(12); stack.Push(50); Console.WriteLine("Pop: " + stack.Pop()); stack.Push(-115); stack.Push(65); stack.Push(22); Console.WriteLine("Peek: " + stack.Peek()); stack.Push(512); stack.Push(602); stack.Push(16); Console.WriteLine("Pop: " + stack.Pop()); Console.WriteLine(string.Join(" -> ", stack)); }
static void Main(string[] args) { MyStack t = new MyStack(); //Push 10 elements onto the stack for (int i = 0; i < 10; i++) { t.PushElement(i); } Console.WriteLine("Current Stack Values!"); t.print_Elements(); //Pop the last element: Remove the last element t.PopElement(); //print the contents of the Stack Console.WriteLine("The Contents of the stack is: "); t.print_Elements(); //Print the top element of the stack Console.WriteLine("Top Element of the stack: {0}", t.PeekElement()); t.print_Elements(); }