This commit is contained in:
2026-10-20 16:04:38 +02:00
parent bf705d701d
commit 0f9049cfa5
36 changed files with 527 additions and 6 deletions
BIN
View File
Binary file not shown.
+36
View File
@@ -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;
}
BIN
View File
Binary file not shown.
+31
View File
@@ -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;
}