31 lines
548 B
C
31 lines
548 B
C
# include <stdio.h>
|
|
# include <stdlib.h>
|
|
|
|
int main(void) {
|
|
int aleatoire;
|
|
int i;
|
|
int entree;
|
|
int VALEUR_MAX;
|
|
int NB_TENTATIVES;
|
|
VALEUR_MAX = 100;
|
|
NB_TENTATIVES = 5;
|
|
srand(time(NULL));
|
|
aleatoire = (rand() % VALEUR_MAX);
|
|
for (i = 1; i <= NB_TENTATIVES; i++) {
|
|
printf("Entrez un nombre : ");
|
|
scanf("%d", &entree);
|
|
if (entree < aleatoire) {
|
|
printf("+\n");
|
|
}
|
|
else if (entree > aleatoire) {
|
|
printf("-\n");
|
|
}
|
|
else {
|
|
printf("Bonne réponse");
|
|
}
|
|
}
|
|
if (aleatoire != entree) {
|
|
printf("Perdu");
|
|
}
|
|
return EXIT_SUCCESS;
|
|
} |