static void Main(string[] args) { StackByArray <int> stack = new StackByArray <int>(10); stack.Push(1); stack.Push(3); stack.Push(7); stack.Push(8); stack.Push(4); stack.Push(5); while (!stack.isEmpty()) { Console.WriteLine("堆栈弹出的顺序为:" + stack.Pop()); } //StackByLink<int> stackL=new StackByLink<int>(); //stackL.Insert(3); //stackL.Insert(2); //stackL.Insert(6); //stackL.Insert(7); //stackL.Insert(9); //Console.WriteLine("数据加入后堆栈中的内容:"); //stackL.OutputAllStack(); Console.ReadKey(); }
static void Main(string[] args) { int value; StackByArray <int> stack = new StackByArray <int>(10); Console.WriteLine("请按序输入10个数据:"); for (int i = 0; i < 10; i++) { value = int.Parse(Console.ReadLine()); stack.Push(value); } Console.WriteLine(); while (!stack.isEmpty()) { Console.WriteLine("堆栈弹出的顺序为:" + stack.Pop()); } Console.ReadKey(); }