Título: Iniciar, Pausar, Reiniciar un cronometro en c++ Publicado por: Avijobat en 13 Marzo 2015, 23:02 pm Esto es solo el cronometro pero he intentado hacerlo las funciones y nomas no se me dan, no he podido asignar estas funciones a teclas...
#include <iostream> #include <time.h> #include <conio.h> #include <cstdlib> using namespace std; void delay (double seconds) { clock_t endwait; endwait = clock() + seconds * CLOCKS_PER_SEC; while (clock() < endwait) {} } int main() { int hr, mn, sg, cs, hr1, mn1, sg1, cs1; for (hr=0; hr<=2; hr++) { for (hr1=0; hr1<=9; hr1++) { for (mn=0; mn<=5; mn++) { for (mn1=0; mn1<=9; mn1++) { for (sg=0; sg<=5; sg++) { for (sg1=0; sg1<=9; sg1++) { for (cs=0; cs<60; cs++) { cout<<"------> CHRONOMETER <------"<<endl<<endl; cout<<hr<<hr1<<":"<<mn<<mn1<<":"<<sg<<sg1<<":"<<cs; delay(0.01); system ("cls"); } } } } } } } return 0; } Título: Re: Iniciar, Pausar, Reiniciar un cronometro en c++ Publicado por: ivancea96 en 14 Marzo 2015, 11:32 am void delay (unsigned int milliseconds) { clock_t endwait; endwait = clock() + (milliseconds * CLOCKS_PER_SEC)/1000; while (clock() < endwait) {} } Te diría que trabajes con milisegundos ahí, ya que no hay necesidad de usar decimales. Por lo demás, no me fijé si había algo mal. |