Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- struct Stack<G>
- {
- public G[] arr;
- public int top;
- public void Push(G val)
- {
- if (top < arr.Length - 1)
- {
- top++;
- arr[top] = val;
- }
- }
- public void Pop()
- {
- if (top == -1)
- {
- Console.WriteLine("Stack is empty");
- }
- else
- {
- Console.WriteLine(arr[top]);
- top--;
- }
- }
- }
- static void Main(string[] args)
- {
- Stack<int> s;
- s.top = -1;
- s.arr = new int[5];
- s.Push(1);
- s.Push(5);
- s.Push(7);
- s.Pop();
- }
- }
Add Comment
Please, Sign In to add comment