static void CalculaQuick() { FileStream arq = new FileStream("RelatorioQuick.txt", FileMode.OpenOrCreate); StreamWriter write = new StreamWriter(arq); Dados[] A; List <double> time; write.WriteLine("Valor de I;Caso Médio;Melhor Caso;Pior Caso"); for (int i = 2000; i <= 8000; i *= 2) { time = new List <double>(); write.Write("{0};", i); for (int j = 0; j < 5; j++) { var watch = System.Diagnostics.Stopwatch.StartNew(); A = new Dados[i]; CasoMed(A); QuickSort(A, 0, A.Length - 1); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds / 1000.0; Console.WriteLine(elapsedMs); time.Add(elapsedMs); } double med = MediaTempo(time); write.Write("{0};", Math.Round(med, 3)); time = new List <double>(); A = new Dados[i]; for (int j = 0; j < 5; j++) { var watch = System.Diagnostics.Stopwatch.StartNew(); PiorCaso(A); QuickSort(A, 0, A.Length - 1); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds / 1000.0; time.Add(elapsedMs); } med = MediaTempo(time); write.Write("{0};", Math.Round(med, 3)); time = new List <double>(); for (int j = 0; j < 5; j++) { var watch = System.Diagnostics.Stopwatch.StartNew(); A = new Dados[i]; MelhorCaso(A); QuickSort(A, 0, A.Length - 1); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds / 1000.0; time.Add(elapsedMs); } med = MediaTempo(time); write.WriteLine("{0}", Math.Round(med, 3)); } write.Close(); arq.Close(); }