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
|
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char** argv )
{
int nombre1 = 0, nombre2 = 0, compteur = 0, partie = 1;
const int MAX = 100, MIN = 1;
srand(time(NULL));
nombre1 = (rand() % (MAX - MIN + 1)) + MIN;
do
{
do
{
printf("quel est le nombre ? \n");
scanf("%d", &nombre2);
compteur++;
if(nombre1 > nombre2)
printf("c'est plus !\n");
else if (nombre1 < nombre2)
printf("c'est moin!\n");
else
printf("bravo tu as trouve le nombre mystere !!!\n");
printf("tu as trouve le nombre mystere en %d coups" ,compteur);
}while(nombre1 != nombre2);
printf("tu veux rejoue:\n");
printf("1:oui\n");
printf("0:non\n");
scanf("%d",&partie);
}while(partie);
return 0;
} |
Partager