Slide 11
Slide 11 text
Yoan Thirion
#sharingiscaring
Que se passe-t-il lorsqu’on
lit du code ?
MLT
MCT
Filtre MCT
MLT
MDT
1 2
4
3
public class InsertionSort {
public static void main(String[] args) {
int[] array = {45, 12, 85, 32, 89, 39, 69, 44, 42, 1, 6, 8};
int temp;
for (int i = 1; i < array.length; i++) {
for (int j = i; j > 0; j--) {
if (array[j] < array[j - 1]) {
temp = array[j];
array[j] = array[j - 1];
array[j - 1] = temp;
}
}
}
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}
int[] array
int temp
2 boucles
public static void main(String[] args)
for (int i = 1; i < array.length; i++)…
public class InsertionSort {
public static void main(String[] args) {
int[] array = {45, 12, 85, 32, 89, 39, 69, 44, 42, 1, 6, 8};
int temp;
for (int i = 1; i < array.length; i++) {
for (int j = i; j > 0; j--) {
if (array[j] < array[j - 1]) {
temp = array[j];
array[j] = array[j - 1];
array[j - 1] = temp;
}
}
}
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}
Code reproduit
Les informations extraites de notre MLT dépendent de ce qu’on y a stocké.
Une personne moins expérimentée en Java est susceptible d'extraire beaucoup moins d'informations de sa MLT.