public static void MainTest(string[] args) { var stack = new Stack <string>(); TextInput StdIn = new TextInput(); while (!StdIn.IsEmpty) { string item = StdIn.ReadString(); if (!item.Equals("-")) { stack.Push(item); } else if (!stack.IsEmpty) { Console.Write(stack.Pop() + " "); } } Console.WriteLine("(" + stack.Size + " left on stack)"); }
public static void MainTest(string[] args) { TextInput StdIn = new TextInput(); BST <string, int> st = new BST <string, int>(); for (int i = 0; !StdIn.IsEmpty; i++) { string key = StdIn.ReadString(); st[key] = i; } foreach (string s in st.Keys()) { Console.WriteLine("{0} {1}", s, st.Get(s)); } Console.WriteLine(); foreach (string s in st.LevelOrder()) { Console.WriteLine(s + " " + st[s]); } }