Entrainement

This commit is contained in:
Simoes Lukas 2024-10-14 15:51:23 +02:00
parent f4b9936c0c
commit a379ee9e1f
5 changed files with 108 additions and 0 deletions

View 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;
}

View File

@ -0,0 +1,7 @@
# include <stdio.h>
# include <stdlib.h>
int main(void){
printf(" _ ,_, _\n / `'=) (='` \\\n/.-.-.\\/.-.-.\\\n` \" `\n");
return EXIT_SUCCESS;
}

View 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;
}

View 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;
}

View File

@ -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;
}