Created
August 3, 2014 19:44
-
-
Save PifyZ/2953183b414864abc601 to your computer and use it in GitHub Desktop.
Plus ou moins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
int main (int argc, char *argv[]) { | |
srand(time(NULL)); | |
int nb_rand = rand() % 100; | |
int saisie = -1; | |
int nb_essais = 0; | |
do { | |
printf("Essai n%d = ", nb_essais + 1); | |
scanf("%d", &saisie); | |
nb_essais++; | |
if (saisie > nb_rand) | |
printf("C'est moins.\n"); | |
if (saisie < nb_rand) | |
printf("C'est plus.\n"); | |
} while (saisie != nb_rand); | |
printf("Victoire ! En %d essais.", nb_essais); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment