multiple, andor multiplications multiples

This commit is contained in:
glazk0 2023-10-07 19:58:41 +02:00
parent 32cd61dadb
commit bef67514a9
No known key found for this signature in database
GPG key ID: E45BF177782B9FEB
3 changed files with 55 additions and 0 deletions

15
semaine-3/and-or/main.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int tourellePrincipaleActive = 0, pourcentageArmesSecondairesActives = 71, radarActif = 0;
if ((tourellePrincipaleActive || pourcentageArmesSecondairesActives > 70) && radarActif) {
printf("Vaisseau sécurisé");
} else {
printf("Alerte sécurité");
}
return EXIT_SUCCESS;
}

17
semaine-3/multiple/main.c Normal file
View file

@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i, element, list[] = {1281, 3281, 5281, 7481, 8281, 9581, 108281};
size_t n = sizeof(list) / sizeof(int);
for (i = 0; i < n; ++i) {
element = list[i];
if (element % 7 == 0 && element % 13 == 0) {
printf("%d\n", element);
}
}
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
#define TARGET 10
#define MAX 9
int main(void) {
int i, j, n = 0, result;
for (i = 1; i <= MAX; i++) {
for (j = 1; j <= TARGET; j++) {
result = i * j;
if ((result % 2 == 0 && result % 4 == 0) && result % 3 != 0) {
n++;
}
}
}
printf("%d", n);
return EXIT_SUCCESS;
}