Files
DEV/DEV1.1/TP08/devi.c
T

36 lines
738 B
C
Raw Normal View History

2026-10-20 16:04:38 +02:00
#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;
}