Last active
May 19, 2022 12:32
-
-
Save DIEGOHORVATTI/e84391eb6a9322ccbe2f6184f8cad367 to your computer and use it in GitHub Desktop.
Verificar tempo de execução de programa em C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> //clock(), CLOCKS_PER_SEC e clock_t | |
int main(void){ | |
printf(" %s", "Ler 3 valores e escrevê-los em ordem crescente.\n\n"); | |
int maior, menor, piloto=3, notas[piloto], cache_maior=0; | |
maior=menor=0; | |
for (int i=1; i <= piloto; i++){ | |
printf(" Digite um valor[%d]: ", i); | |
scanf("%d", ¬as[i]); | |
if(notas[i] > maior){ | |
maior=notas[i]; | |
} | |
if(notas[i] < maior){ | |
menor=notas[i]; | |
} | |
if (i == 3){ | |
printf("\n Maior valor é %d\n", maior); | |
printf("\n Menor valor é %d\n", menor); | |
} | |
} | |
// Cabeçalho de teste de execução | |
clock_t t; //variável para armazenar tempo | |
t = clock(); //armazena tempo | |
t = clock() - t; //tempo final - tempo inicial | |
printf("\n Tempo de execução: %lf", ((double)t)/((CLOCKS_PER_SEC/1000))); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment