1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| #include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
long heures = 0, minutes = 0, masseCorporelle = 0, nombreConsommations = 0, masseAlcool[0], i = 0;
double alcoolemie = 0;
char choix = 0, sexe = 0, chaine[3] = "", *finChaine = NULL;
/*time_t timestamp = 0;*/
system("cls");
printf("-------------------------[MENU]");
printf("\n[1] Calcul de base");
printf("\n[2] Calcul en temps réel");
printf("\n[3] Quitter le programme");
printf("\nVotre choix : ");
choix = getchar();
while (getchar() != '\n');
system("cls");
printf("\n-------------------------[PROFIL]");
printf("\nVotre sexe [h/f] : ");
sexe = getchar();
while (getchar() != '\n');
printf("Votre masse corporelle en Kg : ");
fgets(chaine, sizeof chaine, stdin);
//clean(chaine, stdin);
masseCorporelle = strtol(chaine, &finChaine, 10);
if(choix == '1')
{
printf("\n-------------------------[CONSOMMATION]");
printf("\nLa masse d'alcool que vous avez ingéré en Gr : ");
fgets(chaine, sizeof chaine, stdin);
//clean(chaine, stdin);
masseAlcool[nombreConsommations] = strtol(chaine, &finChaine, 10);
printf("\n-------------------------[RESULTAT]");
//alcoolemie = calculAlcoolemie(sexe, masseCorporelle, masseAlcool);
printf("\nVotre alcoolemie est de %.2f grammes par litre de sang.", alcoolemie);
if(alcoolemie > 0.5)
{
//eliminationAlcool(&heures, &minutes, alcoolemie - 0.50); // 0.50 est la taux d'alcool au volant limité en France
printf("\nAttention! Attendez %ld heures et %ld minutes avant de prendre le volant.", heures, minutes);
}
if(alcoolemie < 0.5)
{
printf("\nVous pouvez prendre le volant.");
}
//eliminationAlcool(&heures, &minutes, alcoolemie);
printf("\nVotre alcoolemie sera nul dans %ld heures et %ld minutes.\n\n", heures, minutes);
}
system("PAUSE");
return 0;
} |