-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stack
42 lines (36 loc) · 811 Bytes
/
Stack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
namespace Test
{
public class Stack<T>
{
public int Top = -1;
public T [] Array = new T[5];
public void Push(T item)
{
if (this.Top < 4)
{
this.Top++;
Array[Top] = item;
}
else
{
Console.WriteLine("Stack is full");
}
}
public void Pop()
{
if (this.Top >= 0)
{
Array[Top] = default(T);
this.Top--;
}
else
{
Console.WriteLine("Stack is empty");
}
}
}
}