From 87fa32a945f74d8675d5e7e0497d7277bca2987e Mon Sep 17 00:00:00 2001 From: pourchot Date: Thu, 12 Oct 2023 12:26:02 +0200 Subject: [PATCH] 12 Octobre --- DEV3.2/TP1/Listes/Main.java | 25 ++++++++++ DEV3.2/TP1/Listes/Reponses | 3 ++ DEV3.2/TP1/Tableaux/Main$1.class | Bin 0 -> 668 bytes DEV3.2/TP1/Tableaux/Main.class | Bin 0 -> 610 bytes DEV3.2/TP1/Tableaux/Main.java | 21 ++++++++ DEV3.2/TP2/Appels.class | Bin 0 -> 1352 bytes DEV3.2/TP2/Appels.java | 30 +++++++++++ DEV3.2/TP2/Tableaux.class | Bin 0 -> 1943 bytes DEV3.2/TP2/Tableaux.java | 83 +++++++++++++++++++++++++++++++ 9 files changed, 162 insertions(+) create mode 100644 DEV3.2/TP1/Listes/Main.java create mode 100644 DEV3.2/TP1/Listes/Reponses create mode 100644 DEV3.2/TP1/Tableaux/Main$1.class create mode 100644 DEV3.2/TP1/Tableaux/Main.class create mode 100644 DEV3.2/TP1/Tableaux/Main.java create mode 100644 DEV3.2/TP2/Appels.class create mode 100644 DEV3.2/TP2/Appels.java create mode 100644 DEV3.2/TP2/Tableaux.class create mode 100644 DEV3.2/TP2/Tableaux.java diff --git a/DEV3.2/TP1/Listes/Main.java b/DEV3.2/TP1/Listes/Main.java new file mode 100644 index 0000000..36dc6a1 --- /dev/null +++ b/DEV3.2/TP1/Listes/Main.java @@ -0,0 +1,25 @@ +import java.awt.*; +import java.util.*; + +public class Main{ + + public static void main(String[] args) { + + ArrayList ListI = new ArrayList(); + ArrayList ListF = new ArrayList(); + ArrayList ListN = new ArrayList(); + int I = 3; + Float F = 5.27f; + Long L = 555165l; + + ListI.add(I); + ListI.add(F); + ListI.add(L); + ListF.add(I); + ListF.add(F); + ListF.add(L); + ListN.add(I); + ListN.add(F); + ListN.add(L); + } +} \ No newline at end of file diff --git a/DEV3.2/TP1/Listes/Reponses b/DEV3.2/TP1/Listes/Reponses new file mode 100644 index 0000000..5e574b4 --- /dev/null +++ b/DEV3.2/TP1/Listes/Reponses @@ -0,0 +1,3 @@ +a) La liste integer ne peut pas recevoir de float ni de long et la liste float ne peut recevoir ni int ni long. + +b) La liste Number pourra recevoir la liste Integer et Float. \ No newline at end of file diff --git a/DEV3.2/TP1/Tableaux/Main$1.class b/DEV3.2/TP1/Tableaux/Main$1.class new file mode 100644 index 0000000000000000000000000000000000000000..57caa2def273e93b8d554bab0aaa29d6591ec791 GIT binary patch literal 668 zcmZvZ%TK~U5XQgdRjEZ#0iWPI@``BU4MJjwCM2K-h!;;wX|SYhO)36WUc6x9!FcwM zGS1c>pnBN-rjy@Hzn%H|e*XY)i6a#;WL1Q*p`2xKO-j zh&1hi!H{g5!nmD|`-aoweTy=RZjYb1L(yrWJ>t*2YH=~Fc3sC5!`k0Wu@xZi`XfVk z=Se>!$#~Zs3hqv2|N30Bg`%lzTGgg!gS)mf&-peQH3qe7PaWO3F{SHxhnwO|+NC#L z3*E9OWVd6ukM=-8Uc(;tH7p^n;Q)sWso={rXh_hMWS`>;2CXH8;WRBinHZA={?{r) z+G`Q;N`sXhNXDLI3lDRz^xez($Ne$)Y=+D~gD$pkP8*DYHbUDC(;@ftrBak5Wu(#4 z8`vua49j#&7zB`eB{86G*{zSM!XNE|yL`4Ki Zf>4^v*$VpdMjSf|oING*j>1_Og+(f=P}()HY+(hf2G%UBW5YrTn+CQllu;oK zg<_ca7C7&8#ZB~8>PL=iA4$m{XmC9YBz@WbHBf@DCnLu2M&R|h() { + @Override + public int compare(String s1, String s2) { + return s1.compareTo(s2); + } + }); + + // Afficher le tableau trié + System.out.println(Arrays.toString(args)); + + } +} \ No newline at end of file diff --git a/DEV3.2/TP2/Appels.class b/DEV3.2/TP2/Appels.class new file mode 100644 index 0000000000000000000000000000000000000000..c00369b29964bc8c73f3b9d2e62d1a2c55ba4677 GIT binary patch literal 1352 zcmaJ=%TgOh6g@4CG-4PG$UJNVVz6-{aAFL8BthT+atNq!;*?zRB8#L!Z5SlYs5C8C zvG*r<;mR@_mlrHTsvH-KY_iKP-;t_(fGd8SmXshDs%*M%-^aP<-0uG4&GBylK0(1j zAI5s%V!Q_v$fPjoz{6CU(aXmAz+vpeG=w?MU^a~yKCBesuGVU*5?wW!E(S2@;tcw2%(=LR zd4ZVc*;sIK9XA99*1}Lnx-M&XmEH?WQGXIQQ@G`F7N5HK3^!a1VK{|F8#xzCSWe-# z34Ts(twsbnA@%k4zA{2OT*ZS(t12fDHW(OgDe%L&d!(-^Ldj}Q;A|7)eYZfOW|CNy z?Izs83RVTutM%PRm2>w>zdzq@=tWNmj8Ic5wqZMfx=*VCdW=^9C*v(!Q z&Ux@ZK<}X+EP4j-%!$UWFxVC7smXezT6R}@yvL-N@|I2YNVd?esf{%=%XNY26L>#( z6qZ%{dRq$C`8dM*fsGAfZiQjFQ4?@CgFw~u6&Xc}vYvL1sEyIO(+wGvDk_?873NNB z@9?}=c>kcLx}FjkE(j~^lS69$hEPg^gLcpMYY z-u}%~=9oEn0h@8_hhGrOI8S~=!a2-j9Q6_@e>Hx~8n#Td)LCz_{;#H&HN^3b+1cQD zhin*wp|nW;hFA}5vQJ`^)+IQ&f?mv1<8`WAqOwg!zv2FXRo|0-nF2;wnMUFt#KbEM zjlD*%MZ+MB;#^za3dO~lH$EF*cnN1E-l8%&N#4ioVd$I;C=H9b7szFdv2m^wtUga) djNUJ}JH*Z7OWdLNBF{sNU!rfixn`T|m3K({H+=vA literal 0 HcmV?d00001 diff --git a/DEV3.2/TP2/Appels.java b/DEV3.2/TP2/Appels.java new file mode 100644 index 0000000..8485308 --- /dev/null +++ b/DEV3.2/TP2/Appels.java @@ -0,0 +1,30 @@ +public class Appels { + + public static int indentation; + + public static long fact(long n){ + for (int i = 0; i < indentation; i++) { + System.out.print(" "); + } + System.out.println("Argument début: "+n); + indentation++; + if(n==1l){ + //Thread.dumpStack(); + return 1; + }else{ + long r=n*fact(n-1l); + for (int i = 0; i < indentation-1; i++) { + System.out.print(" "); + } + indentation--; + System.out.println("Argument fin: "+r); + return r; + } + } + + public static void main(String args[]){ + long x=Long.parseLong(args[0]); + indentation=0; + System.out.println(x+"! = "+fact(x)); + } +} \ No newline at end of file diff --git a/DEV3.2/TP2/Tableaux.class b/DEV3.2/TP2/Tableaux.class new file mode 100644 index 0000000000000000000000000000000000000000..c22b36821e94abc08e06fb50fd4b5ace1db72ce1 GIT binary patch literal 1943 zcmaKs%TgOh6o&uS9U*R#1&$>gg@BO;5Ev31BXA7Z1lbb8#$_*9B!e`-7->c|8c}AS zJV17-tg^_G1<4|zC>IZqhf3w|(Fln^vgym|bIx}z-Tl|!7ncAY;Z+y|7z^WbjEB*W zi5@(_WRyo!VN7F24q16HD~CBbJe0$H6arIGcrX>jmq9EF1eSF}x1R`j)0wvdzIC&r z2@Di;L)&WB_B88_x>uEw*IKP!)f>)MZGI5Am)qX5zG%JmP09HbH62aGa8pLV@YgmuqnH)xNH-b-aFM@;|k{Au)c?cT< zp*D{WJEbb^z1PaNz)(k&H*D=dvuIIQnJBjc@$}8|%6fHq+Bs?18Vlq#o6?}AubZ>m z?1jyaXlgAN#y8j$@Q9SaNKHM`)=i_V+V6DxkgJBR8aB%wPvw7ZO_tDb@n_fFiE9)wb@7=SgKJ;l@Im( zeV$gDSEgFSUP_4|^0NL#f$>i1bmQ1O(%k#k%56g}+op9AM2YviV46qGx5^PCd~;IQZc*=kC9T%yx=Zc4SXZmn9o^P) zL2L_5+{o{?*aYtXzaBp0qaWb600jB+dEGh6Z(@|Q;Otlag!qjMcA8_r5eoFk$H28z zeG4DFoF@{>rLXb}`ll00V*VVS()8KYQc3u}n?8s4jEWw|)iC^A`w-$hM8`3%l5{*w zsTU%~CEtz9_?99M53(*J_B(t^B6}fy{DFY?^x8fsY3B%?{tMPm!~g+<^c&@e7;D4s z62|xG!YntT1s4`2$zT5&q3=B+d73i{54BawYjO zyrp<&c#pPbyln8h884@vMIYNA_gx_3+y+M&Ui3?${{nrk@EpCaRp&m>OB4Qo9&9rA zJkc-Mt(T0Yz#xh&-4^33G0JUh;1#8>8BmHg9`>-nIm|#`Q0pc0N^^gQ=NZZrXIyZ` GFa800XO=er literal 0 HcmV?d00001 diff --git a/DEV3.2/TP2/Tableaux.java b/DEV3.2/TP2/Tableaux.java new file mode 100644 index 0000000..21037dc --- /dev/null +++ b/DEV3.2/TP2/Tableaux.java @@ -0,0 +1,83 @@ +public class Tableaux{ + + public static int[] RemplisTableaux(String[] arguments, int val, int[] tab){ + if (val == (arguments.length-1)){ + tab[val]=Integer.parseInt(arguments[val]); + return tab; + }else{ + tab[val]=Integer.parseInt(arguments[val]); + return RemplisTableaux(arguments, val+1, tab); + } + } + + public static int AfficheTableaux(int[] tab, int val){ + if (val == (tab.length-1)){ + System.out.println(tab[val]+" "); + return 0; + }else{ + System.out.print(tab[val]+" "); + return AfficheTableaux(tab, val+1); + } + } + + public static int EntierPairs(int[] tab, int val, int pair){ + if (val == (tab.length-1)){ + if ((tab[val]%2)==0){ + pair++; + return pair; + }else{ + return pair; + } + }else{ + if ((tab[val]%2)==0){ + return EntierPairs(tab, val+1, pair+1); + }else{ + return EntierPairs(tab, val+1, pair); + } + } + } + + public static int Maximum(int[] tab, int val, int maxi){ + if (val == (tab.length-1)){ + if (tab[val]>maxi){ + return tab[val]; + }else{ + return maxi; + } + }else{ + if (tab[val]>maxi){ + return Maximum(tab, val+1, tab[val]); + }else{ + return Maximum(tab, val+1, maxi); + } + } + } + + public static int[] InverseTableaux(int[] tab, int val){ + if (val == ((tab.length/2)-1)){ + int temp=tab[val]; + tab[val]=tab[(tab.length-1)-val]; + tab[(tab.length-1)-val]=temp; + return tab; + }else{ + int temp=tab[val]; + tab[val]=tab[(tab.length-1)-val]; + tab[(tab.length-1)-val]=temp; + return InverseTableaux(tab, val+1); + } + } + + public static void main(String args[]){ + int i=0; + int longueur=args.length; + int[] tab=new int[longueur]; + tab = RemplisTableaux(args, 0, tab); + AfficheTableaux(tab, 0); + int p = EntierPairs(tab, 0, 0); + System.out.println("Le tableau contient "+p+" nombre pair."); + int m = Maximum(tab, 0, 0); + System.out.println("Le plus grand chiffre du tableau est: "+m); + tab = InverseTableaux(tab, 0); + AfficheTableaux(tab, 0); + } +} \ No newline at end of file