.
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -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;
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
int i;
|
||||
int est_premier;
|
||||
|
||||
printf("Entrez un entier naturel : ");
|
||||
scanf("%d", &n);
|
||||
|
||||
if (n < 2) {
|
||||
est_premier = 0;
|
||||
} else {
|
||||
est_premier = 1;
|
||||
for (i = 2; i * i <= n; i++) {
|
||||
if (n % i == 0) {
|
||||
est_premier = 0;
|
||||
i = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (est_premier) {
|
||||
printf("%d est un nombre premier.\n", n);
|
||||
} else {
|
||||
printf("%d n'est pas un nombre premier.\n", n);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user