Skip to content
Snippets Groups Projects
Commit 6be1c541 authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

Arrumando o Menu e Função que calcula tempo de maquina~

parent 992e446b
No related branches found
No related tags found
No related merge requests found
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <sys/time.h>
#define TAM 15 //tamanho do vetor #define TAM 15 //tamanho do vetor
#define NUMMAX 50 //constante que tem o máximo de valores #define NUMMAX 50 //constante que tem o máximo de valores
No preview for this file type
...@@ -3,11 +3,27 @@ ...@@ -3,11 +3,27 @@
int main () { int main () {
int Vetor[TAM], Escolhidos[4]; int Vetor[TAM], Escolhidos[4];
struct timeval inicio, final;
int tmili, i, comando;
printf ("1 Para Jogar e 2 Para Comparar Algoritmos\n");
scanf ("%d", &comando);
switch (comando) {
case 1:
LerDados (Escolhidos); LerDados (Escolhidos);
GeraVetor (Vetor); GeraVetor (Vetor);
ImprimeVetor(Vetor);
SelectSort (Vetor); SelectSort (Vetor);
ImprimeVetor (Vetor);
VerificaNumero (Vetor, Escolhidos); 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);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment