36 lines
738 B
C
36 lines
738 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
int main(void) {
|
|
int secret;
|
|
int proposition;
|
|
int tentative;
|
|
int trouve;
|
|
|
|
srand((unsigned int)time(NULL));
|
|
secret = rand() % 101;
|
|
|
|
trouve = 0;
|
|
|
|
for (tentative = 1; tentative <= 5 && !trouve; tentative++) {
|
|
printf("Tentative %d/5 (entre 0 et 100) : ", tentative);
|
|
scanf("%d", &proposition);
|
|
|
|
if (proposition < secret) {
|
|
printf("+\n");
|
|
} else if (proposition > secret) {
|
|
printf("-\n");
|
|
} else {
|
|
trouve = 1;
|
|
}
|
|
}
|
|
|
|
if (trouve) {
|
|
printf("Gagne !\n");
|
|
} else {
|
|
printf("Perdu ! Le nombre etait %d.\n", secret);
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
} |