Fin Controle Machine A et B
This commit is contained in:
parent
a379ee9e1f
commit
841c8eeab1
19
DEV1.1/Entrainements/controle_machine_A/cible.c
Normal file
19
DEV1.1/Entrainements/controle_machine_A/cible.c
Normal file
@ -0,0 +1,19 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
28
DEV1.1/Entrainements/controle_machine_A/coincidences.c
Normal file
28
DEV1.1/Entrainements/controle_machine_A/coincidences.c
Normal file
@ -0,0 +1,28 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user