Esempio n. 1
0
        static void Menu(State _state)
        {
            switch (_state)
            {
            case State.Strong:
                System.Console.Write("Wprowadź rząd silni: ");
                double x = Convert.ToInt16(System.Console.ReadLine());
                x = Algorithms.Strong(x);
                System.Console.Write("\nWynik: {0} ", x);
                Console.ReadKey();
                break;

            case State.F:
                System.Console.Write("Wprowadź indeks elementu ciągu: ");
                int y = Convert.ToInt16(System.Console.ReadLine());
                y = Algorithms.F(y - 1);
                System.Console.Write("\nWynik: {0} ", y);
                Console.ReadKey();
                break;

            case State.bubbleSort:
                System.Console.Write("Wprować ścieżkę: ");
                string pathbubble = System.Console.ReadLine();
                int[]  csv        = CSVHandle.ImportCSV(pathbubble + "./Dane.csv");
                CSVHandle.SaveArrayAsCSV("./noweDane.csv", Algorithms.BubbleSort(csv, csv.Length));
                System.Console.Write("\nPosortowano! Sprawdź plik noweDane.scv");
                Console.ReadKey();
                break;

            case State.quickSort:
                System.Console.Write("Wprować ścieżkę: ");
                string pathQuick = System.Console.ReadLine();
                int[]  csvQuick  = CSVHandle.ImportCSV(pathQuick + "./Dane.csv");
                Algorithms.Quick_Sort(csvQuick, 0, csvQuick.Length - 1);
                CSVHandle.SaveArrayAsCSV("./noweDane.csv", csvQuick);
                System.Console.Write("\nPosortowano! Sprawdź plik noweDane.scv");
                Console.ReadKey();
                break;

            case State.Create:
                System.Console.Write("Wprować ścieżkę do katalogu: ");
                string cereatePath = System.Console.ReadLine();
                System.Console.Write("Wprowadź ilość elementów w pliku csv: ");
                int size = Convert.ToInt32(System.Console.ReadLine());
                CSVHandle.CreatedimArray(size, cereatePath + "./Dane.csv");
                System.Console.Write("\nWygenerowano CSV");
                Console.ReadKey();
                break;

            case State.ConductTimeMeasurement:
                Console.Clear();
                System.Console.Write("\ntestowana funkcja : ");
                System.Console.Write("\n1 - QuickSort ");
                System.Console.Write("\n2 - BubbleSort ");
                System.Console.Write("\n3 - Silnia ");
                System.Console.Write("\n4 - Fibbo \n");
                char rodzajFunkcji = System.Console.ReadKey().KeyChar;
                System.Console.Write("\nilość iteracji/elementów : ");
                int    amountOfElements = Convert.ToInt32(System.Console.ReadLine());
                string plikDanych;
                switch (rodzajFunkcji)
                {
                case '1':
                    plikDanych = "./noweDaneQuick.csv";
                    break;

                case '2':
                    plikDanych = "./noweDaneBubble.csv";
                    break;

                case '3':
                    plikDanych = "./noweDaneStrong.csv";
                    break;

                case '4':
                    plikDanych = "./noweDaneFibbo.csv";
                    break;

                default:
                    throw new Exception("zły tryb wybrany");
                }
                CSVHandle.SaveArrayAsCSV(plikDanych, TimmerHandler.getTimmerArray(amountOfElements, rodzajFunkcji));
                break;

            case State.Tree:
                Wykonywujacy.program();
                break;

            case State.Kopiec:
                Heap.glowneMenu();
                break;
            }
        }
Esempio n. 2
0
        public static string[] getTimmerArray(int iterations, char rodzajFunkcji)
        {
            string[]  timeArray = new string[iterations];
            Stopwatch sw        = new Stopwatch();

            //double strong;
            int[] csv = CSVHandle.ImportCSV("./Dane.csv");
            //int[] newcsv = new int[iterations];
            //int fibbo;

            switch (rodzajFunkcji)
            {
            case '1':
                for (int i = 2; i < iterations; i++)
                {
                    System.Console.Write("\nIteracja: " + (i - 2));
                    sw.Start();
                    Algorithms.Quick_Sort(csv, 0, i);
                    sw.Stop();
                    timeArray[i - 2] = string.Format(i + "," + sw.Elapsed.TotalMilliseconds);
                    sw.Restart();
                    Console.Clear();
                }
                break;

            case '2':
                for (int i = 2; i < iterations; i++)
                {
                    System.Console.Write("\nIteracja: " + (i - 2));
                    sw.Start();
                    Algorithms.BubbleSort(csv, i);
                    sw.Stop();
                    timeArray[i - 2] = string.Format(i + "," + sw.Elapsed.TotalMilliseconds);
                    sw.Restart();
                    Console.Clear();
                }
                break;

            case '3':
                for (int i = 2; i < iterations; i++)
                {
                    System.Console.Write("\nIteracja: " + (i - 2));
                    sw.Start();
                    Algorithms.Strong(i);
                    sw.Stop();
                    timeArray[i - 2] = string.Format(i + "," + sw.Elapsed.TotalMilliseconds);
                    sw.Restart();
                    Console.Clear();
                }
                break;

            case '4':
                for (int i = 2; i < iterations; i++)
                {
                    System.Console.Write("\nIteracja: " + (i - 2));
                    sw.Start();
                    Algorithms.F(i);
                    sw.Stop();
                    timeArray[i - 2] = string.Format(i + "," + sw.Elapsed.TotalMilliseconds);
                    sw.Restart();
                    Console.Clear();
                }
                break;

            //case 5:
            //    Algorithms.heap
            //    break;


            default:
                throw new Exception("to nie jest poprawny wybór");
            }

            return(timeArray);
        }