diff --git a/TP6/a.out b/TP6/a.out new file mode 100755 index 0000000..9aeb9a1 Binary files /dev/null and b/TP6/a.out differ diff --git a/TP6/fonctions.c b/TP6/fonctions.c new file mode 100644 index 0000000..0184734 --- /dev/null +++ b/TP6/fonctions.c @@ -0,0 +1,21 @@ + +#include + +int main () { + + float a = 3.; + float b = 2.; + + float norme(float ,float ); + + printf("%f \n",norme(a,b)); + + return 1; + + } + + + +float norme(float x,float y) { + return x*x+y*y ; +} diff --git a/TP6/lancer.c b/TP6/lancer.c new file mode 100644 index 0000000..81d5371 --- /dev/null +++ b/TP6/lancer.c @@ -0,0 +1,16 @@ +#include +#include + +int main () { + float x,y; + int n=0; // compteur lancers + int n_disc=0; // nb dans le disque + for(n=0;n<1e6;n=n+1) { // boucle lancers + x = (2*(float)rand())/RAND_MAX - 1.; + y = (2*(float)rand())/RAND_MAX - 1.; + // TEST : dans le carre ? + if(x*x+y*y<1) + n_disc=n_disc+1; + } + printf("approx pi = %f\n",(4.*n_disc)/n); +} diff --git a/TP7/a.out b/TP7/a.out new file mode 100755 index 0000000..9810dc9 Binary files /dev/null and b/TP7/a.out differ diff --git a/TP7/affiche.c b/TP7/affiche.c new file mode 100644 index 0000000..4ce573a --- /dev/null +++ b/TP7/affiche.c @@ -0,0 +1,32 @@ +#include + +#define N 3 + +int main () { + + + // int A[N][N] = {1,2,3,4,5,6,7,8,9}; // Initialisation pas magique +int A[N][N] = {4,2,3,2,3,4,3,4,2}; // Initialisation pas magique +void affiche (int, int tab[N][N]); + +affiche(N,A); + + return 1; + +} + + + +void affiche(int n, int tab[n][n]) { // affiche les 4 elements + int i; + int j; + for(i=0;i + +#define N 3 + +int main () { + + + // int A[N][N] = {1,2,3,4,5,6,7,8,9}; // Initialisation pas magique +int A[N][N] = {4,2,3,2,3,4,3,4,2}; // Initialisation pas magique + int B[N][N] = {0}; +void affiche (int, int tab[N][N]); + void matrice_echange(int, int tab[N][N], int tab2[N][N]); + + affiche(N,B); + matrice_echange(N,A,B); + affiche(N,A); + affiche(N,B); + + return 1; + +} + +void matrice_echange(int n, int orig[n][n], int target[n][n]) +{ + int i; + int j; + for(i=0;i