Entrainement
This commit is contained in:
parent
f4b9936c0c
commit
a379ee9e1f
53
DEV1.1/Entrainements/controle_machine_B/canettes.c
Normal file
53
DEV1.1/Entrainements/controle_machine_B/canettes.c
Normal file
@ -0,0 +1,53 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
# define CANETTE 0.6
|
||||
# define PACK 3.39
|
||||
|
||||
int main(void) {
|
||||
double budget;
|
||||
double i;
|
||||
int nb_packs, nb_canettes;
|
||||
nb_packs = 0;
|
||||
nb_canettes = 0;
|
||||
printf("Quel est votre budget ? ");
|
||||
scanf("%lf", &budget);
|
||||
for (i = budget; i > PACK; i -= PACK) {
|
||||
nb_packs++;
|
||||
}
|
||||
budget -= (nb_packs * PACK);
|
||||
for (i = budget; i > CANETTE; i -= CANETTE) {
|
||||
nb_canettes++;
|
||||
}
|
||||
if (nb_packs > 0 && nb_canettes > 0) {
|
||||
if (nb_packs == 1) {
|
||||
printf("1 pack et ");
|
||||
}
|
||||
else {
|
||||
printf("%d packs et ", nb_packs);
|
||||
}
|
||||
if (nb_canettes == 1) {
|
||||
printf("1 unité");
|
||||
}
|
||||
else {
|
||||
printf("%d unités", nb_canettes);
|
||||
}
|
||||
}
|
||||
else if (nb_packs > 0) {
|
||||
if (nb_packs == 1){
|
||||
printf("1 pack");
|
||||
}
|
||||
else {
|
||||
printf("%d packs", nb_packs);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (nb_canettes == 1) {
|
||||
printf("1 unité");
|
||||
}
|
||||
else {
|
||||
printf("%d unités", nb_canettes);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
7
DEV1.1/Entrainements/controle_machine_B/chauve_souris.c
Normal file
7
DEV1.1/Entrainements/controle_machine_B/chauve_souris.c
Normal file
@ -0,0 +1,7 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
printf(" _ ,_, _\n / `'=) (='` \\\n/.-.-.\\/.-.-.\\\n` \" `\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
23
DEV1.1/Entrainements/controle_machine_B/circulation.c
Normal file
23
DEV1.1/Entrainements/controle_machine_B/circulation.c
Normal file
@ -0,0 +1,23 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
char lettre;
|
||||
char fin = 'z';
|
||||
char temp;
|
||||
printf("Entrez une minuscule : ");
|
||||
scanf("%c", &lettre);
|
||||
temp = lettre;
|
||||
while (lettre != fin) {
|
||||
putchar(lettre);
|
||||
lettre++;
|
||||
}
|
||||
putchar('z');
|
||||
fin -= 25;
|
||||
while (fin != temp) {
|
||||
putchar(fin);
|
||||
fin++;
|
||||
}
|
||||
putchar('\n');
|
||||
return EXIT_SUCCESS;
|
||||
}
|
16
DEV1.1/Entrainements/controle_machine_B/coincidences.c
Normal file
16
DEV1.1/Entrainements/controle_machine_B/coincidences.c
Normal file
@ -0,0 +1,16 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int resultats[5];
|
||||
int i;
|
||||
int suite_1[5] = {1, 2, 3, 4, 5};
|
||||
int suite_2[5] = {2, 3, 4, 5, 6};
|
||||
for (i = 0; i != 5; i++) {
|
||||
printf("Jet n°%d : ", i+1);
|
||||
scanf("%d", &resultats[i]);
|
||||
getchar();
|
||||
}
|
||||
/* TO DO */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
printf("%d\n", 31);
|
||||
printf("%o\n", 031);
|
||||
printf("%x\n", 0x31);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user