Add bubble sort #8

Fusionado
cromer fusionados 16 commits de bubblesort en master 2018-11-11 19:17:20 -03:00
Se han modificado 2 ficheros con 23 adiciones y 1 borrados
Mostrando solo los cambios del commit 051f6b75e0 - Mostrar todos los commits

Ver fichero

@@ -18,4 +18,5 @@
void start_timer();
void stop_timer();
void print_timer();
long int get_timer();
#endif

Ver fichero

@@ -15,13 +15,20 @@
#include <stdio.h>
#include <time.h>
#include "timer.h"
/**
* El tiempo que demoró en ejecutar algo
* Cuando empezó el timer
*/
static time_t start_time = 0;
/**
* Cuando terminó el timer
*/
static time_t stop_time = 0;
/**
* Empezar el timer
*/
void start_timer() {
if (start_time != 0) {
fprintf(stderr, "Error: El temporizador ya comenzó!\n");
@@ -32,6 +39,9 @@ void start_timer() {
}
}
/**
* Terminar el timer
*/
void stop_timer() {
if (start_time == 0) {
fprintf(stderr, "Error: El temporizador no ha comenzado todavía!\n");
@@ -41,6 +51,17 @@ void stop_timer() {
}
}
/**
* Imprimir el tiempo de ejecución
*/
void print_timer() {
fprintf(stdout, "Tiempo de ejecución: %ld segundos\n", (long int) (stop_time - start_time));
}
/**
* Devolver el tiempo que demoró en ejecutarse
* @return El tiempo que demoró
*/
long int get_timer() {
return (long int) (stop_time - start_time);
}