39 lines
755 B
C
39 lines
755 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <time.h>
|
||
|
int main(void) {
|
||
|
int chance = 5;
|
||
|
int devin;
|
||
|
int res;
|
||
|
srand(time(NULL));
|
||
|
devin = rand()%101;
|
||
|
printf("res : %d\n", devin);
|
||
|
printf("Devinez le chiffre choisit entre 0 et 100 : ");
|
||
|
while(chance > 0 || res != devin){
|
||
|
scanf("%d", &res);
|
||
|
if(res != devin){
|
||
|
printf("Non.");
|
||
|
chance = chance - 1;
|
||
|
if(res<devin){
|
||
|
printf("C'est +\n");
|
||
|
}
|
||
|
if(res>devin){
|
||
|
printf("C'est -\n");
|
||
|
}
|
||
|
if (chance < 0){
|
||
|
break;
|
||
|
}
|
||
|
}else{
|
||
|
break;
|
||
|
}
|
||
|
printf("Nb chances : %d\n", chance);
|
||
|
printf("Réessayer : ", chance);
|
||
|
}
|
||
|
if (chance < 0){
|
||
|
printf("Perdu!!! La réponse est %d\n", devin);
|
||
|
}
|
||
|
else if (res == devin){
|
||
|
printf("Bonne réponse!!!\n");
|
||
|
}
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|