public static void Main(String[] args) { String[] a = StdIn.ReadAllStrings(); int N = a.Length; MSD.Sort(a); for (int i = 0; i < N; i++) { Console.WriteLine(a[i]); } }
public static void Main(String[] args) { // read in the strings from standard input String[] a = StdIn.ReadAllStrings(); int N = a.Length; // sort the strings Quick3string.Sort(a); // print the results for (int i = 0; i < N; i++) { Console.WriteLine(a[i]); } }
/// <summary> /// Reads in a sequence of strings from standard input, shuffles /// them, and prints out the results. /// </summary> /// <example>Algs4.exe Knuth</example> /// <remarks>End of file is CTRL+Z and hit ENTER /// if you want to have shuffle of 1 2 3 4 5 /// type into command line: 1 2 3 4 5 /// CTRL+Z + hit enter /// </remarks> /// <param name="args">no parameters expected</param> public static void Main(String[] args) { // read in the data String[] a = StdIn.ReadAllStrings(); //shuffle the array Knuth.Shuffle(a); // print results. for (int i = 0; i < a.Length; i++) { Console.WriteLine(a[i]); Debug.WriteLine(a[i]); } }
public static void Main(String[] args) { String[] a = StdIn.ReadAllStrings(); int N = a.Length; // check that strings have fixed length int W = a[0].Count(); for (int i = 0; i < N; i++) { Debug.Assert(a[i].Count() == W, "Strings must have fixed length"); } // sort the strings LSD.Sort(a, W); // print results for (int i = 0; i < N; i++) { Console.WriteLine(a[i]); } }
/// <summary> /// Reads in a sequence of strings from standard input; selection sorts them; /// and prints them to standard output in ascending order. /// </summary> /// <param name="args"></param> public static void Main(String[] args) { String[] a = StdIn.ReadAllStrings(); Quick.Sort(a); show(a); }
/// <summary> /// Reads in a sequence of strings from standard input; selection sorts them; /// and prints them to standard output in ascending order. /// </summary> /// <param name="args"></param> public static void Main(String[] args) { String[] a = StdIn.ReadAllStrings(); Insertion.Sort(a); show(a); }