Guest User

timer

a guest
Mar 6th, 2013
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <time.h>
  4.  
  5. int main (void)
  6. {
  7.     int m = 0, s = 0, pause = 0;
  8.    
  9.     while (!GetAsyncKeyState(VK_ESCAPE))
  10.     {
  11.         printf("escape - quit  /  left/right cursor key - reset/stop\n", m, s);
  12.         printf("%2d:%2d", m, s);
  13.         Sleep(1000);
  14.         system("cls");
  15.        
  16.         if (GetAsyncKeyState(VK_LEFT)) {m = 0; s = 0;}
  17.         if (GetAsyncKeyState(VK_RIGHT)) pause = ~pause;
  18.  
  19.         if (!pause)
  20.         {
  21.  
  22.             s++;
  23.             if (s == 60) {s = 0; m++;}
  24.             if (m == 60)  m = 0;
  25.         }
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment