Пример #1
0
        public void unsortedTenDrawn()
        {
            var        Drawings = new Sorter();
            List <int> input    = new List <int> {
                3, 4, 5, 11, 15, 17, 19, 20, 33, 38
            };

            Drawings.Draw(4);
            Drawings.Draw(5);
            Drawings.Draw(3);
            Drawings.Draw(11);
            Drawings.Draw(15);
            Drawings.Draw(38);
            Drawings.Draw(33);
            Drawings.Draw(20);
            Drawings.Draw(19);
            Drawings.Draw(17);
            List <int> output = Drawings.Balls();

            Assert.AreEqual(input.Count, output.Count);
            output = Drawings.Sorted();
            Assert.AreEqual(output, input);
        }
Пример #2
0
        private static void RunMainProgram()
        {
            Summary summary = new Summary();

            Console.Write("MINIMALNA  WIELKOSC ZBIORU = ");
            int valuesCountMin = int.Parse(Console.ReadLine());

            Console.Write("MAKSYMALNA WIELKOSC ZBIORU = ");
            int valuesCountMax = int.Parse(Console.ReadLine());

            Console.Write("MINIMALNA  WARTOSC = ");
            int valueMin = int.Parse(Console.ReadLine());

            Console.Write("MAKSYMALNA WARTOSC = ");
            int valueMax = int.Parse(Console.ReadLine());

            Console.Write("ILOSC PROBEK = ");
            int samplesCount = int.Parse(Console.ReadLine());

            int diff       = valuesCountMax - valuesCountMin;
            int sampleStep = (diff / samplesCount);

            Random rnd = new Random(Guid.NewGuid().GetHashCode());

            int counterMax = InputGenerator.AllInputTypes.Length * Sorter.AllAlgorithms.Length * samplesCount;
            int counter    = 0;

            Console.WriteLine();
            Console.WriteLine("Rozpoczynam dzialanie");

            foreach (InputGenerator.InputType inputType in InputGenerator.AllInputTypes)
            {
                for (int i = 0; i < samplesCount + 1; i++)
                {
                    int   inputSize = valuesCountMin + (i * sampleStep);
                    int[] input     = InputGenerator.Generate(rnd, inputType, inputSize, valueMin, valueMax);
                    foreach (Sorter.AlgorithmName algorithmName in Sorter.AllAlgorithms)
                    {
                        Sorter.Result result = Sorter.Sort(algorithmName, input);
                        Summary.Row   row    = new Summary.Row(algorithmName, inputType, inputSize, result.Time);
                        summary.AddRow(row);
                        counter++;
                        Console.WriteLine("[" + counter.ToString() + "/" + counterMax.ToString() + "] " + algorithmName.ToString() + " " + inputType.ToString() + " " + result.Time.TotalMilliseconds.ToString() + " ms");
                    }
                }
            }

            string text = string.Empty;

            Summary.Row[] allRows = summary.GetRows();
            for (int i = 0; i < allRows.Length; i++)
            {
                text += allRows[i].Algorithm + ";"
                        + allRows[i].InputType + ";"
                        + allRows[i].InputCount + ";"
                        + allRows[i].Time.TotalMilliseconds.ToString().Replace('.', ',')
                        + System.Environment.NewLine;
            }
            System.IO.File.WriteAllText(OUTPUT_PATH, text);

            Console.WriteLine("Wyniki zostały wyeksportowane do pliku " + OUTPUT_PATH);
            Console.WriteLine("Nacisnij dowolny klawisz, aby kontynuowac.");
            Console.ReadKey();
        }