Ajout TPS + Entrainements
This commit is contained in:
parent
6f3e79de9d
commit
f7764aa296
10
DEV1.1/Entrainements/controle_machine_2_A/Makefile
Normal file
10
DEV1.1/Entrainements/controle_machine_2_A/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
complet : carre.o lightness.o
|
||||
gcc -ansi -pedantic -o carre.o lightness.o
|
||||
carre.o : carre.c
|
||||
gcc -ansi -pedantic -c carre.c
|
||||
lightness.o : lightness.c lightness.h
|
||||
gcc -ansi -pedantic -c lightness.c
|
||||
clean :
|
||||
rm -f carre.o lightness.o
|
||||
run : complet
|
||||
./complet
|
50
DEV1.1/Entrainements/controle_machine_2_A/carre.c
Normal file
50
DEV1.1/Entrainements/controle_machine_2_A/carre.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
#include"lightness.h"
|
||||
|
||||
#define LIGHT 0
|
||||
#define DARK 1
|
||||
#define RED 1
|
||||
#define GREEN 2
|
||||
#define BLUE 4
|
||||
#define LIGHT_RED 217
|
||||
#define DARK_RED 124
|
||||
#define LIGHT_GREEN 157
|
||||
#define DARK_GREEN 34
|
||||
#define LIGHT_BLUE 147
|
||||
#define DARK_BLUE 19
|
||||
|
||||
int hue(void) {
|
||||
int choice = rand()%3;
|
||||
if (choice == 0) {
|
||||
return RED;
|
||||
} else if (choice == 1) {
|
||||
return GREEN;
|
||||
} else /* if (choice == 2) */ {
|
||||
return BLUE;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int l, c, v;
|
||||
|
||||
srand(time(NULL));
|
||||
l = lightness();
|
||||
c = hue();
|
||||
|
||||
if (c == RED) {
|
||||
v = (l == LIGHT) ? LIGHT_RED : DARK_RED;
|
||||
} else if (c == GREEN) {
|
||||
v = (l == LIGHT) ? LIGHT_GREEN : DARK_GREEN;
|
||||
} else /* if (c == BLUE) */ {
|
||||
v = (l == LIGHT) ? LIGHT_BLUE : DARK_BLUE;
|
||||
}
|
||||
|
||||
printf("┏━━━━┓\n");
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┗━━━━┛\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
9
DEV1.1/Entrainements/controle_machine_2_A/ldiv.c
Normal file
9
DEV1.1/Entrainements/controle_machine_2_A/ldiv.c
Normal file
@ -0,0 +1,9 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
ldiv_t quotient = ldiv(strtol(argv[1], NULL, 10), strtol(argv[2], NULL, 10));
|
||||
printf("quotient : %ld\n", quotient.quot);
|
||||
printf("reste : %ld\n", quotient.rem);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
12
DEV1.1/Entrainements/controle_machine_2_A/lightness.c
Normal file
12
DEV1.1/Entrainements/controle_machine_2_A/lightness.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
#include "carre.h"
|
||||
|
||||
int lightness(void) {
|
||||
if (time(NULL)%2) {
|
||||
return LIGHT;
|
||||
} else {
|
||||
return DARK;
|
||||
}
|
||||
}
|
6
DEV1.1/Entrainements/controle_machine_2_A/lightness.h
Normal file
6
DEV1.1/Entrainements/controle_machine_2_A/lightness.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef LIGHTNESS_H
|
||||
#define LIGHTNESS_H
|
||||
|
||||
int lightness(void);
|
||||
|
||||
#endif
|
39
DEV1.1/Entrainements/controle_machine_2_A/suite.c
Normal file
39
DEV1.1/Entrainements/controle_machine_2_A/suite.c
Normal file
@ -0,0 +1,39 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
|
||||
int* suite(int n) {
|
||||
int* p = NULL;
|
||||
int compteur = 0;
|
||||
p = (int*) malloc(sizeof(int));
|
||||
if (p) {
|
||||
p[0] = n;
|
||||
while (!n%2) {
|
||||
compteur++;
|
||||
p = (int*) realloc(p, sizeof(int));
|
||||
n = n/2;
|
||||
p[compteur] = n;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
else {
|
||||
printf("Espace mémoire insuffisant.");
|
||||
}
|
||||
}
|
||||
|
||||
void afficher_tableau(int* t) {
|
||||
int i;
|
||||
size_t max = *(&t + 1) - t;
|
||||
printf("%lu", max);
|
||||
for (i = 0; i != max ; i++) {
|
||||
printf("| %d", t[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
int tab[5] = {2, 5, 8, 9, 1};
|
||||
afficher_tableau(tab);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
11
DEV1.1/Entrainements/controle_machine_2_B/Makefile
Normal file
11
DEV1.1/Entrainements/controle_machine_2_B/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
carre: carre.o hue.o
|
||||
gcc -ansi -pedantic -o carre carre.o hue.o
|
||||
|
||||
carre.o : carre.c
|
||||
gcc -ansi -pedantic -c carre.c
|
||||
|
||||
hue.o : hue.c hue.h
|
||||
gcc -ansi -pedantic -c hue.c
|
||||
|
||||
run : carre
|
||||
./carre
|
48
DEV1.1/Entrainements/controle_machine_2_B/carre.c
Normal file
48
DEV1.1/Entrainements/controle_machine_2_B/carre.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
#include "hue.h"
|
||||
|
||||
#define LIGHT 0
|
||||
#define DARK 1
|
||||
#define RED 1
|
||||
#define GREEN 2
|
||||
#define BLUE 4
|
||||
#define LIGHT_RED 217
|
||||
#define DARK_RED 124
|
||||
#define LIGHT_GREEN 157
|
||||
#define DARK_GREEN 34
|
||||
#define LIGHT_BLUE 147
|
||||
#define DARK_BLUE 19
|
||||
|
||||
int lightness(void) {
|
||||
if (time(NULL)%2) {
|
||||
return LIGHT;
|
||||
} else {
|
||||
return DARK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
int l, c, v;
|
||||
|
||||
srand(time(NULL));
|
||||
l = lightness();
|
||||
c = hue();
|
||||
|
||||
if (c == RED) {
|
||||
v = (l == LIGHT) ? LIGHT_RED : DARK_RED;
|
||||
} else if (c == GREEN) {
|
||||
v = (l == LIGHT) ? LIGHT_GREEN : DARK_GREEN;
|
||||
} else /* if (c == BLUE) */ {
|
||||
v = (l == LIGHT) ? LIGHT_BLUE : DARK_BLUE;
|
||||
}
|
||||
|
||||
printf("┏━━━━┓\n");
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┗━━━━┛\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
11
DEV1.1/Entrainements/controle_machine_2_B/decomposition.c
Normal file
11
DEV1.1/Entrainements/controle_machine_2_B/decomposition.c
Normal file
@ -0,0 +1,11 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <math.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
double partie_entiere;
|
||||
modf(strtod(argv[1], NULL), &partie_entiere);
|
||||
printf("partie entière : %f\npartie décimale : %f\n", partie_entiere, (strtod(argv[1],NULL) - partie_entiere));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
12
DEV1.1/Entrainements/controle_machine_2_B/hue.c
Normal file
12
DEV1.1/Entrainements/controle_machine_2_B/hue.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include "carre.c"
|
||||
|
||||
int hue(void) {
|
||||
int choice = rand()%3;
|
||||
if (choice == 0) {
|
||||
return RED;
|
||||
} else if (choice == 1) {
|
||||
return GREEN;
|
||||
} else /* if (choice == 2) */ {
|
||||
return BLUE;
|
||||
}
|
||||
}
|
6
DEV1.1/Entrainements/controle_machine_2_B/hue.h
Normal file
6
DEV1.1/Entrainements/controle_machine_2_B/hue.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef HUE
|
||||
#define HUE
|
||||
|
||||
int hue(void);
|
||||
|
||||
#endif
|
@ -1,4 +1,78 @@
|
||||
------- TP19 : Allocation dynamique --------
|
||||
|
||||
1.
|
||||
1. # include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int taille_tab;
|
||||
double* tab = (double*) malloc(3*sizeof(double));
|
||||
int* tab_compteurs = (int*) malloc(sizeof(int));
|
||||
int i;
|
||||
int j;
|
||||
printf("Combien de réels souhaitez-vous entrer ? ");
|
||||
scanf("%d", &taille_tab);
|
||||
getchar();
|
||||
tab = (double*) realloc(tab, taille_tab*sizeof(double));
|
||||
tab_compteurs = (int*) realloc(tab_compteurs, taille_tab*sizeof(int));
|
||||
for (i = 0; i != taille_tab; i++) {
|
||||
printf("Entrez le %de réel : ", i + 1);
|
||||
scanf("%lf", &tab[i]);
|
||||
getchar();
|
||||
tab_compteurs[i] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i!=taille_tab; i++) {
|
||||
for (j = 0; j != taille_tab; j++) {
|
||||
if (tab[j] == tab[i]) {
|
||||
tab_compteurs[i] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i!=taille_tab; i++) {
|
||||
if (tab_compteurs[i] == 1) {
|
||||
printf("| %lf ", tab[i]);
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
2.
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
|
||||
char* inverse(const char* s) {
|
||||
int taille_s = strlen(s);
|
||||
char* s_inverse = (char*) malloc(sizeof(char));
|
||||
int i;
|
||||
int j = 0;
|
||||
s_inverse = realloc(s_inverse, taille_s*sizeof(char));
|
||||
for (i = taille_s-1; i>0; i--) {
|
||||
s_inverse[j] = s[i];
|
||||
j++;
|
||||
}
|
||||
s_inverse[j] = s[0];
|
||||
return s_inverse;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int i;
|
||||
for (i = 1; i != argc; i++){
|
||||
if (strcmp(argv[i], inverse(argv[i])) == 0) {
|
||||
printf(argv[i]);
|
||||
printf(" est un palindrome.\n");
|
||||
}
|
||||
else {
|
||||
printf(argv[i]);
|
||||
printf(" n'est pas un palindrome.\n");
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
3.
|
||||
|
||||
|
@ -2,31 +2,34 @@
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int taille_tab;
|
||||
int taille_tab = 0;
|
||||
double entree;
|
||||
double* tab = (double*) malloc(3*sizeof(double));
|
||||
int* tab_compteurs = (int*) malloc(sizeof(int));
|
||||
int i;
|
||||
int j;
|
||||
printf("Combien de réels souhaitez-vous entrer ? ");
|
||||
scanf("%d", &taille_tab);
|
||||
getchar();
|
||||
tab = (double*) realloc(tab, taille_tab*sizeof(double));
|
||||
for (i = 0; i != taille_tab; i++) {
|
||||
printf("Entrez le %de réel : ", i + 1);
|
||||
scanf("%lf", &tab[i]);
|
||||
while( entree != (double) 'q') {
|
||||
taille_tab++;
|
||||
tab = (double*) realloc(tab, sizeof(double));
|
||||
tab_compteurs = (int*) realloc(tab_compteurs, sizeof(int));
|
||||
printf("Entrez le %de réel : ", taille_tab);
|
||||
scanf("%lf", &entree);
|
||||
getchar();
|
||||
tab[taille_tab] = entree;
|
||||
tab_compteurs[taille_tab] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i != (taille_tab - 1); i++) {
|
||||
for (j = i; j != taille_tab; j++) {
|
||||
if (tab[i] == tab[j]) {
|
||||
tab[j] = 0.0;
|
||||
for (i = 0; i!=taille_tab; i++) {
|
||||
for (j = 0; j != taille_tab; j++) {
|
||||
if (tab[j] == tab[i]) {
|
||||
tab_compteurs[i] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i != taille_tab; i++) {
|
||||
if (tab[i] != 0.0) {
|
||||
printf("%.3f ", tab[i]);
|
||||
for (i = 0; i!=taille_tab; i++) {
|
||||
if (tab_compteurs[i] == 1) {
|
||||
printf("| %lf ", tab[i]);
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
|
@ -0,0 +1,80 @@
|
||||
----- TP25 : Listes chaînées -----
|
||||
|
||||
1.
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
|
||||
struct mail {
|
||||
unsigned short valeur;
|
||||
struct mail* suivant;
|
||||
};
|
||||
|
||||
typedef struct mail maillon;
|
||||
|
||||
maillon* creation_liste(void) {
|
||||
int i;
|
||||
maillon* p;
|
||||
maillon* premier;
|
||||
maillon* s;
|
||||
srand(time(NULL));
|
||||
premier = (maillon*) malloc(sizeof(maillon));
|
||||
if (!premier) {
|
||||
printf("Erreur d'allocation mémoire. (1) \n");
|
||||
}
|
||||
premier->valeur = (rand() % 889) + 111;
|
||||
p = premier;
|
||||
for (i = 0; i != 9; i++) {
|
||||
s = (maillon*) malloc(sizeof(maillon));
|
||||
if (!s) {
|
||||
printf("Erreur d'allocation mémoire. (2) \n");
|
||||
}
|
||||
s->valeur = (rand() % 889) + 111;
|
||||
p->suivant = s;
|
||||
p = s;
|
||||
}
|
||||
return premier;
|
||||
}
|
||||
|
||||
void destruction_liste(maillon* liste) {
|
||||
maillon* p = liste;
|
||||
maillon* suivant;
|
||||
while (p != NULL) {
|
||||
suivant = p->suivant;
|
||||
free(p);
|
||||
p = suivant;
|
||||
}
|
||||
printf("Destruction terminée.\n");
|
||||
}
|
||||
|
||||
void afficher_liste(maillon* liste) {
|
||||
maillon* p;
|
||||
for (p = liste; p != NULL; p = p->suivant) {
|
||||
printf("| %d |", p->valeur);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
unsigned short recherche_max(maillon* liste) {
|
||||
unsigned short maximum = liste->valeur;
|
||||
maillon* p;
|
||||
for (p = liste; p != NULL; p = p->suivant) {
|
||||
if (p->valeur > maximum) {
|
||||
maximum = p->valeur;
|
||||
}
|
||||
}
|
||||
return maximum;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
maillon* liste = creation_liste();
|
||||
afficher_liste(liste);
|
||||
printf("Maximum de la liste : %hu\n", recherche_max(liste));
|
||||
destruction_liste(liste);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
2.
|
||||
|
@ -1,28 +1,100 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
|
||||
struct maillon {
|
||||
int valeur;
|
||||
struct maillon* suivant;
|
||||
struct mail {
|
||||
unsigned short valeur;
|
||||
struct mail* suivant;
|
||||
};
|
||||
|
||||
typedef struct mail maillon;
|
||||
|
||||
void creation_liste(struct maillon* liste) {
|
||||
maillon* creation_liste(void) {
|
||||
int i;
|
||||
liste->valeur = (rand() % 888) + 111;
|
||||
for (i = 0; i != 10; i++) {
|
||||
struct maillon* prochain = (struct maillon*) malloc(sizeof(struct maillon*));
|
||||
if (prochain == NULL) {
|
||||
printf("Erreur d'allocation mémoire.\n");
|
||||
maillon* p;
|
||||
maillon* premier;
|
||||
maillon* s;
|
||||
srand(time(NULL));
|
||||
premier = (maillon*) malloc(sizeof(maillon));
|
||||
if (!premier) {
|
||||
printf("Erreur d'allocation mémoire. (1) \n");
|
||||
}
|
||||
prochain->valeur = (rand() % 888) + 111;
|
||||
liste->suivant = prochain;
|
||||
premier->valeur = (rand() % 889) + 111;
|
||||
p = premier;
|
||||
for (i = 0; i != 9; i++) {
|
||||
s = (maillon*) malloc(sizeof(maillon));
|
||||
if (!s) {
|
||||
printf("Erreur d'allocation mémoire. (2) \n");
|
||||
}
|
||||
s->valeur = (rand() % 889) + 111;
|
||||
p->suivant = s;
|
||||
p = s;
|
||||
}
|
||||
return premier;
|
||||
}
|
||||
|
||||
void destruction_liste(maillon* liste) {
|
||||
maillon* p = liste;
|
||||
maillon* suivant;
|
||||
while (p != NULL) {
|
||||
suivant = p->suivant;
|
||||
free(p);
|
||||
p = suivant;
|
||||
}
|
||||
printf("Destruction terminée.\n");
|
||||
}
|
||||
|
||||
void afficher_liste(maillon* liste) {
|
||||
maillon* p;
|
||||
for (p = liste; p != NULL; p = p->suivant) {
|
||||
printf("| %d |", p->valeur);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
unsigned short recherche_max(maillon* liste) {
|
||||
unsigned short maximum = liste->valeur;
|
||||
maillon* p;
|
||||
for (p = liste; p != NULL; p = p->suivant) {
|
||||
if (p->valeur > maximum) {
|
||||
maximum = p->valeur;
|
||||
}
|
||||
}
|
||||
return maximum;
|
||||
}
|
||||
|
||||
void retire_dernier(maillon* liste) {
|
||||
maillon* p;
|
||||
for (p = liste; p != NULL; p = p->suivant) {
|
||||
if (p->suivant->suivant == NULL) {
|
||||
/* Il faut faire pointer l'avant dernier maillon sur NULL */
|
||||
p->suivant = NULL;
|
||||
free(p->suivant);
|
||||
}
|
||||
}
|
||||
printf("Succès.\n");
|
||||
}
|
||||
|
||||
maillon* permutation_liste(maillon* liste) {
|
||||
maillon* p;
|
||||
maillon* temp = liste;
|
||||
for (p = liste; p->suivant != NULL; p = p->suivant) {
|
||||
p = p->suivant;
|
||||
}
|
||||
/* TODO */
|
||||
liste->valeur = p->valeur;
|
||||
liste->suivant = p;
|
||||
return liste;
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
struct maillon* liste = NULL;
|
||||
srand(time(NULL));
|
||||
creation_liste(liste);
|
||||
maillon* liste = creation_liste();
|
||||
afficher_liste(liste);
|
||||
printf("Maximum de la liste : %hu\n", recherche_max(liste));
|
||||
/*retire_dernier(liste);*/
|
||||
/*afficher_liste(liste);*/
|
||||
afficher_liste(permutation_liste(liste));
|
||||
destruction_liste(liste);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
55
DEV1.1/TP27/TP27-reponses.txt
Normal file
55
DEV1.1/TP27/TP27-reponses.txt
Normal file
@ -0,0 +1,55 @@
|
||||
----- TP27 : Récursivité -----
|
||||
|
||||
1.
|
||||
|
||||
|
||||
|
||||
2.
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
|
||||
int fibonacci(int n) {
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (n == 1) {
|
||||
return 1;
|
||||
}
|
||||
return (fibonacci(n-2) + fibonacci(n-1));
|
||||
}
|
||||
|
||||
void affiche_fibonacci(int m) {
|
||||
int i;
|
||||
for (i = 0; i != m; i++) {
|
||||
printf("%d\n", fibonacci(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
/*printf("%d",fibonacci(7));*/
|
||||
affiche_fibonacci(15);
|
||||
}
|
||||
|
||||
3.
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
void affiche_tableau(double* t, int len) {
|
||||
if (sizeof(double)*len == sizeof(double)) {
|
||||
printf("%.2f\n", t[len-1]);
|
||||
}
|
||||
else {
|
||||
printf("%.2lf, ", t[0]);
|
||||
affiche_tableau(&t[1], len-1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
double t[5] = {1.25, 47.80, 77.01, 54.23, 895.14};
|
||||
affiche_tableau(t, 5);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
18
DEV1.1/TP27/test.c
Normal file
18
DEV1.1/TP27/test.c
Normal file
@ -0,0 +1,18 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
void affiche_tableau(double* t, int len) {
|
||||
if (sizeof(double)*len == sizeof(double)) {
|
||||
printf("%.2f\n", t[len-1]);
|
||||
}
|
||||
else {
|
||||
printf("%.2lf, ", t[0]);
|
||||
affiche_tableau(&t[1], len-1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
double t[5] = {1.25, 47.80, 77.01, 54.23, 895.14};
|
||||
affiche_tableau(t, 5);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
8
DEV1.1/TP28/TP28_reponses.txt
Normal file
8
DEV1.1/TP28/TP28_reponses.txt
Normal file
@ -0,0 +1,8 @@
|
||||
----- TP28 : Récursivité (suite) -----
|
||||
|
||||
1.
|
||||
|
||||
|
||||
|
||||
2.
|
||||
|
13
DEV1.1/TP28/test.c
Normal file
13
DEV1.1/TP28/test.c
Normal file
@ -0,0 +1,13 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int f(int n) {
|
||||
if (n>100)
|
||||
return n-10;
|
||||
else
|
||||
return f(f(n+11));
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
f(12);
|
||||
}
|
10
DEV1.1/controle_machine_2_B/decomposition.c
Normal file
10
DEV1.1/controle_machine_2_B/decomposition.c
Normal file
@ -0,0 +1,10 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <math.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int partie_entiere;
|
||||
modf(argv[1], &partie_entiere);
|
||||
printf("partie entière : %f\npartie décimale : %f", partie_entiere, (argv[1] - partie_entiere));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user