44 lines
734 B
C
44 lines
734 B
C
|
#include <stdlib.h>
|
||
|
#include <stdio.h>
|
||
|
#include <time.h>
|
||
|
int main(void)
|
||
|
{
|
||
|
|
||
|
int generate_random(int min, int max){
|
||
|
return min + rand() / (RAND_MAX / (max - min + 1)+1);
|
||
|
|
||
|
void main(){
|
||
|
|
||
|
srand(time(NULL));
|
||
|
|
||
|
int random_number = generate_random(0,100);
|
||
|
int num=0;
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
for(int i = 0; i<5; i++){
|
||
|
printf("Devinez mon nombre entre 1 et 100 \n");
|
||
|
scanf("%d", &num);
|
||
|
|
||
|
if(random_number==num){
|
||
|
|
||
|
printf("Vous avez trouvez mon nombre, gagné !\n");
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
else if(num>random_number){
|
||
|
|
||
|
printf("Le nombre est plus petit\n");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
printf("Le nombre est plus grand\n");
|
||
|
}
|
||
|
}
|
||
|
printf("Le nombre était %d\n", random_number);
|
||
|
}
|
||
|
}
|
||
|
}
|