static void TestDoubleStackList() { //入栈 DoubleStackList <int> d = new DoubleStackList <int>(); PrintDoubleStackList(d, "入栈前:"); d.PushA(0); d.PushA(2); d.PushA(5); d.PushB(4); d.PushB(1); d.PushB(3); d.PushB(1); PrintDoubleStackList(d, "入栈后出栈输出:"); d.PushA(66); d.PushB(33); PrintDoubleStackList(d, "再次入栈测试出栈:"); Console.WriteLine(); //测试栈满 DoubleStackList <int> dd = new DoubleStackList <int>(3); dd.PushA(1); dd.PushB(2); dd.PushA(3); dd.PushA(66); PrintDoubleStackList(dd); }
static void PrintDoubleStackList(DoubleStackList <int> d, string text = "输出:") { //输出A栈 int element = 0; int length = d.GetLengthA(); Console.Write("栈A "); for (int i = 0; i < length; i++) { d.PopA(ref element); Console.Write(element.ToString() + " "); } //栈B出栈并输出 length = d.GetLengthB(); Console.Write("栈B "); for (int i = 0; i < length; i++) { d.PopB(ref element); Console.Write(element.ToString() + " "); } Console.WriteLine(); }