From 5015fcc8248e0083ba8fe9007884a4238694aca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=5BJMF=5D=E2=80=9D?= Date: Thu, 21 Oct 2021 18:58:25 +0200 Subject: [PATCH] TP6/TP7 code TP6 et TP7 --- TP6/a.out | Bin 0 -> 49472 bytes TP6/fonctions.c | 21 ++++++++++++++++++++ TP6/lancer.c | 16 +++++++++++++++ TP7/a.out | Bin 0 -> 49736 bytes TP7/affiche.c | 32 ++++++++++++++++++++++++++++++ TP7/echange.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 120 insertions(+) create mode 100755 TP6/a.out create mode 100644 TP6/fonctions.c create mode 100644 TP6/lancer.c create mode 100755 TP7/a.out create mode 100644 TP7/affiche.c create mode 100644 TP7/echange.c diff --git a/TP6/a.out b/TP6/a.out new file mode 100755 index 0000000000000000000000000000000000000000..9aeb9a1e848efbf644037602ef107f3255701de5 GIT binary patch literal 49472 zcmeI)UuauZ90%}|cA4GQ?WPYC#SO07$X28sA}Yvcs*7g0ZgcHq9lAr(n=XMg4au#x z;6tD)3>g%B@j*ev2OoTpp~Bu$Hz}Kfu)XX-L$XNXT?zwkK?%L-)?0ewc zbAIQX`^!0>{CT_i<-fo0Jfu{lS1Hwl8bkdms?-O{Mo+0nQB$Z|pBQ~Dc_w-CxQup} zNO!nlBzgAX1+<<>o}TDl;@zL<9#ejdtthEm{b{Y;?7Zs-Xu|pILpTh^lW1aWXfpP#S2Kgp+a*+MB>#-eb(2|wSUpFm=9zgzCv z-_&fe(mrrF-+U;a#PVKlR!RlbJ2(l3U(1 zU*IpF*3S16-_@>IYbWid&1=auyuVo0>@PT{#GU!%p3c(#z8^hu?Dgc~BSv4TTIigJ zr6m0CnKXXa8-GHn>H+E1l#}YjP=Epypa2CZKmiI+fC3bt00k&O0SZun z0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC1t{=f z37kru|1-5%w^x$4<=`vHhH2^@QPYY=pT>icO>1bZF>MVmTOVG+^s21E+)f*F>sD;{ zplPEf9=f@1OW~qIQ>mzb-Q=h?bPBG`|Zn1t@yVIrCRataaHQ* zg}vXQGdkXie}-@=CxdH$A#+Y1KVAD3JsGOLKRhZep6pC`jcVZO=qjp`r|c8yQmH&U zZM%x`P;)Mbfpa2CZ zKmiI+fC3bt00k&O0SZun0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CZKmiI+fC3bt z00k&O0SZun0u-PC1t>rP3Q&Lo6rcbFC_sVxF5uw50_1-Mihg_FH^dE4fC3bt00k&O z0SZun0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC z1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CPK!JfL)k!(_K*CulIJ)A_WppNAbh2gjMp-SX z3TAYvoG-f567?Y}r;85yeu-!mRXutpr?d0fsW~^RbJ?`q{`gEfUsUlPtm{>uzvnLx zIxiyLwN0s5)%^c}EVCjpZ + +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 0000000000000000000000000000000000000000..9810dc984007a069818b87eed718e51db23a96e6 GIT binary patch literal 49736 zcmeI5UuauZ9LG=Eb?g4HbTDM1vY@MUBI}eXbuvxo?!0qbS8WS28HY5vX+o1UBsaP$ z!$LP`xD@&*=))d-5EU)>q6M*YgAN&5hDZe;qEt;F!d{di!}|N3b8eH|ZSO=lM5rgk{bV+ol!N^*TBog7PO-PO zgj(et702nJ2S_<=y*k`FMXisv`h?MxieTGlhNX0!v#t@;1mo>LM4KW1O_LPs4UOq6 zrkbUcMYl9sTz3WI^*pcR?J_fb?Jwvw@f!JYJehJbd8a^=g7KmzUY`lTnz^r++wzM~ zdX@u#{sH z4Qh9f$8%MQ>h(sc_pO;D=T#-sdHJ)boeJbdT9v47{Ji`iW09J}DD1H|CGto?m22=htbbux^gmSgCuB@BPHFf#cSZW17AYi-CQT z=3<+TF?aLHDgVQi`F`##3c=6rq*iI_bLm^uzbjMJ4wB|D{Ee-U-b(HKCH)?7pU1iQ z&){=u{!LJWfog`I{I=8f6w+h7E~kbvUPLGdXM?ov*(r<_E4vKjjjtm@fYcf zT7OO2o-JMcimwe;yObKaNSCmgnwOTt*t}~aD`}|zPyQ3;!;u|qJ>qIL{R$VWxtE|!_mMp%GOSxB- z>mcIn*O1+?k|K8b1AAs?KfJN;wzrDpSZ_CYuCAVfO}V| zN3ALwsHPKDcXIufef)y>W8I0(>Mkpv@`Getnp3GT!$J=;rTRJED-9kF0+?bI)nL+vxp=wC*;#V)WB`9fwlIrkcdMel4Km0X-hj#enW0y@{-o zjM5ex$+nOM{ShJWz)Jd@WHv^OsBWdya<=NET0Hu+{bS>n56nNR+g<=Em5WaD^_c5W Hl2rZ$xajZT literal 0 HcmV?d00001 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