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 0000000..57caa2d Binary files /dev/null and b/DEV3.2/TP1/Tableaux/Main$1.class differ diff --git a/DEV3.2/TP1/Tableaux/Main.class b/DEV3.2/TP1/Tableaux/Main.class new file mode 100644 index 0000000..7eb99d3 Binary files /dev/null and b/DEV3.2/TP1/Tableaux/Main.class differ diff --git a/DEV3.2/TP1/Tableaux/Main.java b/DEV3.2/TP1/Tableaux/Main.java new file mode 100644 index 0000000..28fc138 --- /dev/null +++ b/DEV3.2/TP1/Tableaux/Main.java @@ -0,0 +1,21 @@ +import java.awt.*; +import java.util.*; +import java.util.Arrays; +import java.util.Comparator; + +public class Main{ + + public static void main(String[] args) { + // Tri avec un comparateur de chaînes + Arrays.sort(args, new Comparator() { + @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 0000000..c00369b Binary files /dev/null and b/DEV3.2/TP2/Appels.class differ 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 0000000..c22b368 Binary files /dev/null and b/DEV3.2/TP2/Tableaux.class differ 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