Advertisement
gallopelado

Ejercicio del reloj Hibrido C/C++

Oct 25th, 2013
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <iostream>
  4. #include <cstdlib>
  5. using namespace std;
  6. void delay(unsigned int mseconds)
  7. {
  8. clock_t goal = mseconds + clock();
  9. while (goal > clock());
  10. }
  11.  
  12. int main(void)
  13. {
  14. int hora=0,segundo=0, minuto=0;
  15.  
  16.     for(segundo = 0; segundo <60; segundo++)
  17.     {
  18.  
  19.         delay(  1000000  );//aqui pusimos 1000x1000
  20.         system("clear");//aqui limpiamos pantalla
  21.        cout<<hora<<" : "<<minuto<<" : "<<segundo<<endl;
  22.        //printf("%d : %d : %d",hora, minuto, segundo);
  23.             if(segundo == 59)
  24.                 {
  25.                     segundo=0;
  26.                     minuto = minuto + 1;
  27.                 }
  28.                     if(minuto == 59)
  29.                     {
  30.                         segundo=0;
  31.                         minuto = 0;
  32.                         hora = hora + 1;
  33.                     }
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement