public static void Test0() { //Passed //var inputFileName = @"Data\data_examples_03\input__10.txt"; ; //var outputFileName = @"Data\data_examples_03\output__10.txt"; //var inputFileName = @"Data\data_examples_03\input__100.txt"; ; //var outputFileName = @"Data\data_examples_03\output__100.txt"; var inputFileName = @"Data\data_examples_03\input__1000.txt";; var outputFileName = @"Data\data_examples_03\output__1000.txt"; int[] array1 = null; int[] array2 = null; int[] array3 = null; var fileInfo = new FileInfo(inputFileName); var fileStream = fileInfo.OpenRead(); var textReader = new StreamReader(fileStream); var i = 0; var row = textReader.ReadLine(); array1 = new int[Convert.ToInt32(row)]; array2 = new int[Convert.ToInt32(row)]; array3 = new int[Convert.ToInt32(row)]; while (!textReader.EndOfStream) { row = textReader.ReadLine(); array1[i] = Convert.ToInt32(row); array2[i] = Convert.ToInt32(row); array3[i] = Convert.ToInt32(row); //Console.Write(row); ++i; } //Console.WriteLine("----------------------------"); var s1 = new QuickSortLast(array1); var s1Result = s1.Sort(); var s2 = new QuickSortFirst(array2); var s2Result = s2.Sort(); var s3 = new QuickSortMedian(array3); var s3Result = s3.Sort(); fileInfo = new FileInfo(outputFileName); fileStream = fileInfo.OpenRead(); textReader = new StreamReader(fileStream); Console.WriteLine("Output:{0} ---> ({1},{2},{3})", textReader.ReadToEnd(), s1Result, s2Result, s3Result); //Console.WriteLine("----------------------------"); }
public static void TestQuickSortFirst() { //int[] array = { 3, 4, 9, 1, 8, 7, 2, 6, 5, 10 }; int[] array = { 18, 3, 4, 15, 9, 1, 8, 11, 7, 2, 16, 6, 13, 5, 10, 12, 20, 14, 19, 17, }; var sort = new QuickSortFirst(array); Console.WriteLine("Количество сравненений:{0}", sort.Sort()); //for (var ind = 0; ind < array.Length; ++ind) //{ // Console.Write("{0},", array[ind]); //} Console.WriteLine(); }
public static void Task2() { var fileName = @"Data\input__10000.txt"; var fileInfo = new FileInfo(fileName); var fileStream = fileInfo.OpenRead(); var textReader = new StreamReader(fileStream); int[] array = null; var i = 0; var row = textReader.ReadLine(); array = new int[Convert.ToInt32(row)]; while (!textReader.EndOfStream) { row = textReader.ReadLine(); array[i] = Convert.ToInt32(row); Console.Write("{0},", array[i]); ++i; } Console.WriteLine(); var sort = new QuickSortFirst(array); Console.WriteLine("Количество сравненений:{0}", sort.Sort()); //for (i = 0; i < array.Length; ++i) //{ // Console.Write("{0},", array[i]); //} Console.WriteLine(); }