- /* PROGRAMME EN C SOUS DOS TURBO C++2 BORLAND
- ecrit le 11-06-2002 par cmarsc
- derniere modification 1-05-2004
- chronometre */
-
-
- #include <stdio.h>
- #include <time.h>
- #include <conio.h> /* <conio.c>devc++4 */
- #include <stdlib.h>
- #include <dos.h>
-
- #define KEY_ENTER 13 /* touche du clavier ENTREE */
- #define KEY_ESC 27 /* touche du clavier ESCAPE */
- #define KEY_F2 60 /* touche du clavier F2 */
-
- #define COUL_ECRAN LIGHTCYAN /* couleur fond d'ecran */
-
- enum reponse { NON, OUI };
-
- int chronometre(void);
-
-
- int main(void)
- {
-
- int recommencer = OUI;
- time_t heure_actuelle;
- char entree_clavier;
-
- textbackground(COUL_ECRAN);
- clrscr();
- _setcursortype(_NOCURSOR);
-
- do {
-
- textcolor(BLUE); textbackground(LIGHTGRAY);
- gotoxy(20,5);
- cputs(" ENTREE lancer le chrono ESC pour quitter ");
-
- entree_incorrect:
-
- do { /* afficher l'heure actuelle sans arret */
-
- time(&heure_actuelle);
- gotoxy(20,12);
- cprintf(" HEURE ACTUELLE : %9.8s ",ctime(&heure_actuelle)+11);
-
- } while (!kbhit());
-
- entree_clavier = getch();
-
- /* quitter le programme */
- if ( entree_clavier == KEY_ESC ) {
- exit(EXIT_SUCCESS);
-
- } else if ( entree_clavier != KEY_ENTER ) {
- /* oblige a taper sur ENTREE et pas sur une autre touche */
- goto entree_incorrect;
-
- } /* fin de if (entree_clavier ...) */
-
- gotoxy(20,5);
- cputs(" F2 Recommencer ESC pour quitter ");
-
- recommencer = chronometre();
-
- } while (recommencer != NON);
-
- return (EXIT_SUCCESS);
- } /* fin de la fonction main */
-
-
- int chronometre(void) {
-
- char entree_clavier;
- time_t heure_depart, heure_fin, heure_actuelle;
-
- clock_t depart, fin;
- int minutes, heures, secondes,secondes_totales;
- int recommencer;
-
- heure_depart = time(NULL); /* heure du systeme */
-
- time(&heure_depart);
- textcolor(WHITE); textbackground(GREEN);
- gotoxy(20,8);
- cprintf(" HEURE DE DEPART : %9.8s ",ctime(&heure_depart)+11);
-
- /* effacer la ligne qui affiche l'heure de fin */
- textcolor(COUL_ECRAN); textbackground(COUL_ECRAN);
- gotoxy( 1, 9 );
- cprintf("%80c",'\0');
-
-
- depart = clock();
- textcolor(WHITE); textbackground(BLUE);
-
- do {
-
-
- do {
- time(&heure_actuelle);
- gotoxy(20,12);
- cprintf(" HEURE ACTUELLE : %9.8s ",ctime(&heure_actuelle)+11);
-
- fin = clock();
-
- secondes_totales = (fin - depart) / CLK_TCK;
-
- heures = secondes_totales / 3600;
- minutes = (secondes_totales - heures * 3600) / 60;
- secondes = secondes_totales - heures * 3600 - minutes * 60;
-
- gotoxy(20,14);
- cprintf(" Heure(s) %02d : minute(s) %02d seconde(s) %02d ",
- heures,minutes,secondes);
-
- gotoxy(20,16);
- cprintf(" %02d:%02d:%02d ",heures,minutes,secondes );
-
- } while (!kbhit());
-
- entree_clavier = getch();
-
- } while (entree_clavier != KEY_ESC && entree_clavier != KEY_F2);
-
- textcolor(WHITE); textbackground(RED);
-
- time(&heure_fin);
- gotoxy(20, 9);
- cprintf(" HEURE DE FIN : %9.8s ",ctime(&heure_fin)+11);
-
- /* determiner si l'on relance le chrono ou pas */
- recommencer = (entree_clavier == KEY_ESC) ? NON : OUI;
-
- return recommencer;
- } /* fin de la fonction chronometre */
-
/* PROGRAMME EN C SOUS DOS TURBO C++2 BORLAND
ecrit le 11-06-2002 par cmarsc
derniere modification 1-05-2004
chronometre */
#include <stdio.h>
#include <time.h>
#include <conio.h> /* <conio.c>devc++4 */
#include <stdlib.h>
#include <dos.h>
#define KEY_ENTER 13 /* touche du clavier ENTREE */
#define KEY_ESC 27 /* touche du clavier ESCAPE */
#define KEY_F2 60 /* touche du clavier F2 */
#define COUL_ECRAN LIGHTCYAN /* couleur fond d'ecran */
enum reponse { NON, OUI };
int chronometre(void);
int main(void)
{
int recommencer = OUI;
time_t heure_actuelle;
char entree_clavier;
textbackground(COUL_ECRAN);
clrscr();
_setcursortype(_NOCURSOR);
do {
textcolor(BLUE); textbackground(LIGHTGRAY);
gotoxy(20,5);
cputs(" ENTREE lancer le chrono ESC pour quitter ");
entree_incorrect:
do { /* afficher l'heure actuelle sans arret */
time(&heure_actuelle);
gotoxy(20,12);
cprintf(" HEURE ACTUELLE : %9.8s ",ctime(&heure_actuelle)+11);
} while (!kbhit());
entree_clavier = getch();
/* quitter le programme */
if ( entree_clavier == KEY_ESC ) {
exit(EXIT_SUCCESS);
} else if ( entree_clavier != KEY_ENTER ) {
/* oblige a taper sur ENTREE et pas sur une autre touche */
goto entree_incorrect;
} /* fin de if (entree_clavier ...) */
gotoxy(20,5);
cputs(" F2 Recommencer ESC pour quitter ");
recommencer = chronometre();
} while (recommencer != NON);
return (EXIT_SUCCESS);
} /* fin de la fonction main */
int chronometre(void) {
char entree_clavier;
time_t heure_depart, heure_fin, heure_actuelle;
clock_t depart, fin;
int minutes, heures, secondes,secondes_totales;
int recommencer;
heure_depart = time(NULL); /* heure du systeme */
time(&heure_depart);
textcolor(WHITE); textbackground(GREEN);
gotoxy(20,8);
cprintf(" HEURE DE DEPART : %9.8s ",ctime(&heure_depart)+11);
/* effacer la ligne qui affiche l'heure de fin */
textcolor(COUL_ECRAN); textbackground(COUL_ECRAN);
gotoxy( 1, 9 );
cprintf("%80c",'\0');
depart = clock();
textcolor(WHITE); textbackground(BLUE);
do {
do {
time(&heure_actuelle);
gotoxy(20,12);
cprintf(" HEURE ACTUELLE : %9.8s ",ctime(&heure_actuelle)+11);
fin = clock();
secondes_totales = (fin - depart) / CLK_TCK;
heures = secondes_totales / 3600;
minutes = (secondes_totales - heures * 3600) / 60;
secondes = secondes_totales - heures * 3600 - minutes * 60;
gotoxy(20,14);
cprintf(" Heure(s) %02d : minute(s) %02d seconde(s) %02d ",
heures,minutes,secondes);
gotoxy(20,16);
cprintf(" %02d:%02d:%02d ",heures,minutes,secondes );
} while (!kbhit());
entree_clavier = getch();
} while (entree_clavier != KEY_ESC && entree_clavier != KEY_F2);
textcolor(WHITE); textbackground(RED);
time(&heure_fin);
gotoxy(20, 9);
cprintf(" HEURE DE FIN : %9.8s ",ctime(&heure_fin)+11);
/* determiner si l'on relance le chrono ou pas */
recommencer = (entree_clavier == KEY_ESC) ? NON : OUI;
return recommencer;
} /* fin de la fonction chronometre */