This commit is contained in:
Geoffrey Frogeye 2016-04-20 11:19:01 +02:00
parent e7efbd99c5
commit 34f6792698
3 changed files with 73 additions and 0 deletions

36
TP4/E6.c Normal file
View file

@ -0,0 +1,36 @@
/* Tri */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[]) {
int n, *P1, *P2, min, *minP;
printf("Saississez la taille du tableau : ");
scanf("%d", &n);
int T[n];
for (P1 = T; P1 < T+n; P1++) {
printf("T[%d] = ", P1-T);
scanf("%d", P1);
}
for (P1 = T; P1 < T+n; P1++) {
for (P2 = P1; P2 < T+n; P2++) {
if (*P2 < min || P2 == P1) {
min = *P2;
minP = P2;
}
}
*minP = *P1;
*P1 = min;
}
// Affichage
for (P1 = T; P1 < T+n; P1++) {
printf("%d, ", *P1);
}
printf("\n");
return 0;
}

28
TP5/E1.c Normal file
View file

@ -0,0 +1,28 @@
/* Composition de fonctions */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
double f(double x) {
return pow(x, 3) + 2 * pow(x, 2) + 3 * x - 4;
}
double g(double x) {
return 1 - x;
}
double composition(double(*Pf)(double x), double(*Pg)(double x), double x) {
return (*Pf)((*Pg)(x));
}
int main(int argc, char *argv[]) {
double(*Pf)(double x) = &f;
double(*Pg)(double x) = &g;
double a = -1;
printf("fog(%lf) = %lf\n", a, composition(Pf, Pg, a));
printf("gof(%lf) = %lf\n", a, composition(Pg, Pf, a));
printf("fof(%lf) = %lf\n", a, composition(Pf, Pf, a));
printf("gog(%lg) = %lg\n", a, composition(Pg, Pg, a));
return 0;
}

9
TP5/Makefile Normal file
View file

@ -0,0 +1,9 @@
all: $(patsubst %.c,%.exe,$(shell ls *.c))
%.exe: %.c
gcc -g $< -o $@ -lm
.PHONY: all clean
clean:
rm *.exe