diff --git a/Arquivos/Loteria b/Arquivos/Loteria index 9b691119028aa40a59e5988ad5f3e9c42a8f0814..509528b3fa08820abcd5e135393ef3357f695f36 100755 Binary files a/Arquivos/Loteria and b/Arquivos/Loteria differ diff --git a/Arquivos/Main.c b/Arquivos/Main.c index 57b25dde8307697eeae618e521a6440b243ea842..86042194d836d10464530ea9a8c5598c692a47cb 100644 --- a/Arquivos/Main.c +++ b/Arquivos/Main.c @@ -29,6 +29,34 @@ void TempoBubbleSort (int *Vetor) { printf ("O BubbleSort Demorou %d Centesimos\n", tmili); } +void TempoQuickSortRecursivo (int *Vetor) { + struct timeval inicio, final; + int tmili, i; + + gettimeofday(&inicio, NULL); + for (i = 0; i < 10000; i ++) { + GeraVetor(Vetor); + QuickSortRecursivo (Vetor, 0, TAM); + } + gettimeofday(&final, NULL); + tmili = (int) (1000 * (final.tv_sec - inicio.tv_sec) + (final.tv_usec - inicio.tv_usec) / 1000); + printf ("O QuickSort Recursivo Demorou %d Centesimos\n", tmili); +} + +void TempoQuickSortIterativo (int *Vetor) { + struct timeval inicio, final; + int tmili, i; + + gettimeofday(&inicio, NULL); + for (i = 0; i < 10000; i ++) { + GeraVetor(Vetor); + QuickSortIterativo (Vetor, 0, TAM); + } + gettimeofday(&final, NULL); + tmili = (int) (1000 * (final.tv_sec - inicio.tv_sec) + (final.tv_usec - inicio.tv_usec) / 1000); + printf ("O QuickSort Iterativo Demorou %d Centesimos\n", tmili); +} + int main () { int Vetor[TAM], Escolhidos[4]; int comando; @@ -46,5 +74,7 @@ int main () { case 2: TempoSelectSort (Vetor); TempoBubbleSort (Vetor); + TempoQuickSortRecursivo (Vetor); + TempoQuickSortIterativo (Vetor); } }