//BARRA DE ESTÁTISTICAS private void bolhaToolStripMenuItem1_Click_1(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.Bolha(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 Bolha", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void bolhaToolStripMenuItem1_Click_1(object sender, EventArgs e) { int tamanhovet = Convert.ToInt32(comboBox1.Text); int[] vetor = new int[tamanhovet]; // TODO (tamanho deverá ser escolhido pelo usuário) string auxPreenchi = ""; int[] vetReturn = new int[2]; if (rdbCresc.Checked == true) { Preenchimento.Crescente(vetor); auxPreenchi = "Crescente"; } else if (rdbDesc.Checked == true) { Preenchimento.Decrescente(vetor); auxPreenchi = "Decrescente"; } else { Preenchimento.Aleatorio(vetor, 1000); auxPreenchi = "Aleatório"; } var stopwatch = new Stopwatch(); stopwatch.Start(); // inicia cronômetro vetReturn = OrdenacaoEstatistica.Bolha(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: " + auxPreenchi + "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) + "\nNº de comparações: " + vetReturn[0] + "\nNº de trocas: " + vetReturn[1], "Estatísticas do Método Bolha", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void bolhaToolStripMenuItem1_Click_1(object sender, EventArgs e) { int[] vetor = new int[1000]; // TODO (tamanho deverá ser escolhido pelo usuário) Preenchimento.Aleatorio(vetor, 1000); // TODO (preenchimento inicial deverá ser escolhido pelo usuário) var stopwatch = new Stopwatch(); stopwatch.Start(); // inicia cronômetro OrdenacaoEstatistica.Bolha(vetor); stopwatch.Stop(); // interrompe cronômetro long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido MessageBox.Show(this, "Tamanho do vetor: TODO" + "\nOrdenação inicial: TODO" + "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) + "\nNº de comparações: TODO" + "\nNº de trocas: TODO", "Estatísticas do Método Bolha", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void bolhaToolStripMenuItem1_Click_1(object sender, EventArgs e) { int[] vetor = new int[tamVet]; // TODO (tamanho deverá ser escolhido pelo usuário) switch (codOrdenacao) { case 0: Preenchimento.Crescente(vetor); break; case 1: Preenchimento.Decrescente(vetor); break; case 2: Preenchimento.Aleatorio(vetor, tamVet); break; } var stopwatch = new Stopwatch(); stopwatch.Start(); // inicia cronômetro OrdenacaoEstatistica.Bolha(vetor); stopwatch.Stop(); // interrompe cronômetro long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido MessageBox.Show(this, "Tamanho do vetor: " + tamVet + "\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 Bolha", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void IniciaEstatisticas(OrdenacaoEstatistica estatistica, int NumeroMetodo) { int TA; String NomeMetodo = "Inicial"; if (!Int32.TryParse(tamanhoArray.Text, out TA)) { TA = 1000; tamanhoArray.Text = "1000"; } int[] vetor = new int[TA]; if (TipoOrdenacao.Text == "Aletorio") { Preenchimento.Aleatorio(vetor, 300); } else if (TipoOrdenacao.Text == "Decrecente") { Preenchimento.Decrescente(vetor, 300); } else { Preenchimento.Crescente(vetor, 300); TipoOrdenacao.Text = "Crecente"; } var stopwatch = new Stopwatch(); stopwatch.Start(); // inicia cronômetro estatistica.cont_c = 0; //zera os contadores do metodo ordenaçãoestatistica estatistica.cont_t = 0; switch (NumeroMetodo) { case 0: //Bolha estatistica.Bolha(vetor); NomeMetodo = "Bolha"; break; case 1: //Inserção estatistica.Insercao(vetor); NomeMetodo = "Inserção"; break; case 2: //Selecão estatistica.selecao(vetor); NomeMetodo = "Selecao"; break; case 3: //QuickSort estatistica.quickSort(vetor, 0, vetor.Length - 1); NomeMetodo = "QuickSort"; break; case 4: //HeapSort estatistica.heapSort(vetor); NomeMetodo = "HeapSort"; break; case 5: //MergeSort estatistica.mergeSort(vetor, 0, vetor.Length - 1); NomeMetodo = "MergeSort"; break; case 6: //ShellSort estatistica.shellSort(vetor); NomeMetodo = "ShellSort"; break; default: //QuickSort estatistica.quickSort(vetor, 0, vetor.Length - 1); NomeMetodo = "QuickSort"; break; } stopwatch.Stop(); // interrompe cronômetro long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido MessageBox.Show(this, "Tamanho do vetor: " + vetor.Length + "\nOrdenação inicial: " + TipoOrdenacao.Text + "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) + "\nNº de comparações: " + estatistica.cont_c + "\nNº de trocas: " + estatistica.cont_t, "Estatísticas do Método " + NomeMetodo, MessageBoxButtons.OK, MessageBoxIcon.Information); }