diff --git a/Arquivos/Estruturas.h b/Arquivos/Estruturas.h index 1691c17a8e07916cf5a67104a7c61d3ccbbc3bf0..e481e12d956610042797aaf74535466b2aa12a19 100644 --- a/Arquivos/Estruturas.h +++ b/Arquivos/Estruturas.h @@ -3,5 +3,6 @@ #include <time.h> #include <stdlib.h> #include <stdbool.h> +#include <sys/time.h> #define TAM 15 //tamanho do vetor #define NUMMAX 50 //constante que tem o máximo de valores diff --git a/Arquivos/Loteria b/Arquivos/Loteria index fe40f16d2243958a4fd7d8feb3359288be132722..f2fd0e853897eb862df53e08efb4fb7fe483f85a 100755 Binary files a/Arquivos/Loteria and b/Arquivos/Loteria differ diff --git a/Arquivos/Main.c b/Arquivos/Main.c index 71ca5b91ca0b00c9dd4770583530f7046f5a12b9..c7dcc9ba7c570a0f96b5e7d6c5787b2ccf5c286c 100644 --- a/Arquivos/Main.c +++ b/Arquivos/Main.c @@ -3,11 +3,27 @@ int main () { int Vetor[TAM], Escolhidos[4]; + struct timeval inicio, final; + int tmili, i, comando; - LerDados (Escolhidos); - GeraVetor(Vetor); - ImprimeVetor(Vetor); - SelectSort (Vetor); - ImprimeVetor (Vetor); - VerificaNumero (Vetor, Escolhidos); + printf ("1 Para Jogar e 2 Para Comparar Algoritmos\n"); + scanf ("%d", &comando); + switch (comando) { + case 1: + LerDados (Escolhidos); + GeraVetor (Vetor); + SelectSort (Vetor); + VerificaNumero (Vetor, Escolhidos); + ImprimeVetor (Vetor); + break; + case 2: + gettimeofday(&inicio, NULL); + for (i = 0; i < 10000; i ++) { + GeraVetor(Vetor); + SelectSort (Vetor); + } + gettimeofday(&final, NULL); + tmili = (int) (1000 * (final.tv_sec - inicio.tv_sec) + (final.tv_usec - inicio.tv_usec) / 1000); + printf ("O SelectSort Demorou %d Centesimos\n", tmili); + } }