static void PrintStackLink(StackLink <int> s, string text = "输出:") { int element = 0; int length = s.GetLength(); Console.Write(text); for (int i = 0; i < length; i++) { s.Pop(ref element); Console.Write(element.ToString() + " "); } Console.WriteLine(); }
static void TestStackLink() { //入栈 StackLink <int> s = new StackLink <int>(); PrintStackLink(s, "入栈前:"); s.Push(2); s.Push(9); s.Push(10); PrintStackLink(s, "依次出栈输出:"); Console.WriteLine(); //清空栈测试 s.Push(100); s.Push(200); s.ClearStack(); PrintStackLink(s, "清空栈后:"); }