.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user