示例#1
0
        private void heapsortToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            int tamanhoVet = DefineTamanho();

            int[]  vetor         = new int[tamanhoVet];
            string nomeOrdenacao = "";

            vetor = PreecheVetTipo(vetor, out nomeOrdenacao, tamanhoVet);

            var stopwatch = new Stopwatch();

            stopwatch.Start();                                 // inicia cronômetro
            OrdenacaoEstatistica.HeapSort(vetor);
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            $"Tamanho do vetor: {tamanhoVet}" +
                            $"\nOrdenação inicial: {nomeOrdenacao}" +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            $"\nNº de comparações: {OrdenacaoEstatistica.cont_c}" +
                            $"\nNº de trocas: {OrdenacaoEstatistica.cont_t}",
                            "Estatísticas do Método HeapSort",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
示例#2
0
        private void heapsortToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string preenchimento = "";

            vet = new int[Convert.ToInt32(comboBox1.SelectedValue)];
            Preenchimento.Aleatorio(vet, vet.Length);

            var stopwatch = new Stopwatch();

            stopwatch.Start();                                 // inicia cronômetro
            IniciarAnimacao(() => OrdenacaoEstatistica.HeapSort(vet));
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            "Tamanho do vetor: " + vet.Length +
                            "\nOrdenação inicial: " + preenchimento +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            "\nNº de comparações: " + OrdenacaoEstatistica.contTest +
                            "\nNº de trocas: " + OrdenacaoEstatistica.contTrocas,
                            "Estatísticas do Método HeapSort",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
            OrdenacaoEstatistica.contTest   = 0;
            OrdenacaoEstatistica.contTrocas = 0;
        }