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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
| #include <mylib.h>
#include <stdio.h>
#include <stdlib.h>
/* prototypes */
/*--------------*/
int traiter_minimum () ;
int traiter_maximum () ;
int generer_nombres (long int MAX , long int MIN) ;
char operateur (long int nombre1 , long int nombre2) ;
int proposition_enoncer (long int resultat , long int proposition );
int compar_reponse (long int resultat , long int proposition ,long int nbressais, double point);
int main()
{
double point ;
long int concecutif ;
long int nbressais ;
long int resultat ;
long int proposition ;
long int MAX;
long int MIN;
long int nombre1;
long int nombre2;
cls (BLEU);
gotoxy (1, 1); printf ("%45s", "DEVOIR 6");
gotoxy (2, 1); printf ("%45s", "========");
randomize();
concecutif = 3 ;
nbressais = 0 ;
MIN = traiter_minimum() ;
MAX = traiter_maximum() ;
proposition = 0;
do
{
nombre1 = (rand() % (MAX - MIN + 1));
nombre2 = (rand() % (MAX - MIN + 1));
resultat = operateur(nombre1 , nombre2);
lire_long_int (&proposition, 4, 11, 5, 0, 9999);
nbressais = nbressais + 1;
compar_reponse (resultat , proposition , nbressais, point);
if ((nbressais >= 5) && (point <7.5)){
gotoxy (15,1 );printf("Vous obtenez un score de %.2lf/10 ",point);
nbressais = 0 ;
point = 0.0;
concecutif = concecutif - 1 ;
}
if (concecutif ==0){
gotoxy (18,1 );printf("Veuillez revoir vos tables de multiplication!!!",point);
}
}while (!((point >= 7.5) && (nbressais >= 5) || (concecutif == 0)));
gotoxy (15,1 );printf("Vous obtenez un score de %.2lf/10 \n",point);
system("PAUSE");
return 0;
}
int traiter_minimum ()
/*--------------------*/
{
long int MINIMUM = 0;
gotoxy (16,1 );printf("MINIMUM");
lire_long_int (&MINIMUM, 16, 11, 6, 0, 999999);
return MINIMUM;
}
int traiter_maximum ()
/*--------------------*/
{
long int MAXIMUM = 0;
gotoxy (17,1 );printf("MAXIMUM");
lire_long_int (&MAXIMUM, 17, 11, 6, 0, 999999);
return MAXIMUM;
}
char operateur (long int nombre1 , long int nombre2)
/*--------------------------------------------------*/
{
long int resultat ;
long int MAX;
long int MIN;
char car = ' ' ;
gotoxy (18, 1);printf("operateur");
lire_char (&car,18,15,NULL);
gotoxy (4, 1);printf("%ld %c %ld = ",nombre1,car,nombre2);
{
if (car == '+') {
resultat = nombre1 + nombre2;
}
if (car == '-') {
resultat = nombre1 - nombre2;
}
if (car == '*') {
resultat = nombre1 * nombre2;
}
if (car == '/') {
resultat = nombre1 / nombre2;
}
if (car == '%') {
resultat = nombre1 % nombre2;
}
return resultat ;
}
}
int compar_reponse (long int resultat , long int proposition , long int nbressais,
double point)
/*-------------------------------------------------------------------------------*/
{
if(resultat == proposition){
point = point + 2.0;
gotoxy (5,2 );printf("BRAVO LA REPONSE EST CORECTE \n");
gotoxy (6,2);printf("Point : %.2lf \n", point);
}
else {
point = point - 0.5;
gotoxy (5,2);printf("Non la reponse correcte est %ld \n", resultat);
gotoxy (6,2);printf("Point : %.2lf \n", point);
}
gotoxy (15,2);printf("%.2lf \n", point);
return point ;
} |
Partager