public static void MainTest(string[] args) { TextInput StdIn = new TextInput(); string[] a = StdIn.ReadAllStrings(); Heap.Sort(a); OrderHelper.Show(a); }
/// <summary> /// Demo test for the <c>TextInput</c> data type. The test shows /// the methods' behavior and how to use them. /// </summary> /// <param name="args">Place holder for user arguments</param> public static void MainTest(string[] args) { TextInput StdIn = new TextInput(); Console.Write("Type 3 char, 1 integer, a few strings: "); char[] c = { StdIn.ReadChar(), StdIn.ReadChar(), StdIn.ReadChar() }; int a = StdIn.ReadInt(); string s = StdIn.ReadLine(); Console.WriteLine("3 char: {0}, 1 int: {1}, new line: {2}", new string(c), a, s); Console.Write("Type a string: "); s = StdIn.ReadString(); Console.WriteLine("Your string was: " + s); Console.WriteLine(); Console.Write("Type an int: "); a = StdIn.ReadInt(); Console.WriteLine("Your int was: " + a); Console.WriteLine(); Console.Write("Type a bool: "); bool b = StdIn.ReadBool(); Console.WriteLine("Your bool was: " + b); Console.WriteLine(); Console.Write("Type a double: "); double d = StdIn.ReadDouble(); Console.WriteLine("Your double was: " + d); Console.WriteLine(); Console.WriteLine("Enter a line:"); s = StdIn.ReadLine(); Console.WriteLine("Your line was: " + s); Console.WriteLine(); Console.Write("Type any thing you like, enter Ctrl-Z to finish: "); string[] all = StdIn.ReadAllStrings(); Console.WriteLine("Your remaining input was:"); foreach (var str in all) { Console.Write(str + " "); } Console.WriteLine(); }
public static void MainTest(string[] args) { TextInput StdIn = new TextInput(); string[] a = StdIn.ReadAllStrings(); OrderHelper.Show(a); // shuffle StdRandom.Shuffle(a); // display results again using select Console.WriteLine(); for (int i = 0; i < a.Length; i++) { string ith = (string)Quick.Select(a, i); Console.WriteLine(ith); } }