diff --git a/DEV1.1/Entrainements/controle_machine_A/cible.c b/DEV1.1/Entrainements/controle_machine_A/cible.c new file mode 100644 index 0000000..ebaac27 --- /dev/null +++ b/DEV1.1/Entrainements/controle_machine_A/cible.c @@ -0,0 +1,19 @@ +# include +# include + +int main(void) { + char lettre; + char debut; + printf("Entrez une minuscule : "); + scanf("%c", &lettre); + for (debut = 'a'; debut != lettre; debut++) { + putchar(debut); + } + printf("[%c]", lettre); + lettre++; + for (debut = ('z' + 1); debut != lettre; lettre++) { + putchar(lettre); + } + putchar('\n'); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/Entrainements/controle_machine_A/coincidences.c b/DEV1.1/Entrainements/controle_machine_A/coincidences.c new file mode 100644 index 0000000..53eb5cf --- /dev/null +++ b/DEV1.1/Entrainements/controle_machine_A/coincidences.c @@ -0,0 +1,28 @@ +# include +# include + +int main(void) { + int resultats[5]; + int i; + int max; + int compteur_occurences; + for (i = 0; i != 5; i++) { + printf("Jet n°%d : ", i+1); + scanf("%d", &resultats[i]); + getchar(); + } + max = resultats[0]; + for (i = 0; i != 5; i++) { + if (resultats[i] > max) { + max = resultats[i]; + } + } + compteur_occurences = 0; + for (i = 0; i != 5; i++) { + if (max == resultats[i]) { + compteur_occurences++; + } + } + printf("Occurences maximum : %d\n", compteur_occurences); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/Entrainements/controle_machine_B/coincidences.c b/DEV1.1/Entrainements/controle_machine_B/coincidences.c index 7e1ef4f..d7f8e79 100644 --- a/DEV1.1/Entrainements/controle_machine_B/coincidences.c +++ b/DEV1.1/Entrainements/controle_machine_B/coincidences.c @@ -3,7 +3,11 @@ int main(void) { int resultats[5]; + int tab_trie[5]; int i; + int j; + int min; + int temp; int suite_1[5] = {1, 2, 3, 4, 5}; int suite_2[5] = {2, 3, 4, 5, 6}; for (i = 0; i != 5; i++) { @@ -11,6 +15,24 @@ int main(void) { scanf("%d", &resultats[i]); getchar(); } - /* TO DO */ + min = resultats[0]; + for (j = 0; j != 5; j++) { + for (i = 0; i != 5; i++) { + if (min >= resultats[i] && resultats[i] != 0) { + min = resultats[i]; + temp = i; + } + } + tab_trie[j] = min; + resultats[temp] = 7; /* On prend une valeur en dehors des valeurs autorisées */ + min = resultats[0]; /* Ce qui fait qu'on aura toujours un minimum qui n'a pas déjà été traité */ + } + for (i = 0; i != 5; i++) { + if (tab_trie[i] != suite_1[i] && tab_trie[i] != suite_2[i]) { + printf("Ce n'est pas une suite"); + return EXIT_SUCCESS; + } + } + printf("C'est une suite"); return EXIT_SUCCESS; } \ No newline at end of file