Bonjour,

Je cherche à présent à faire un tri par insertion: voici mon programme.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
	public static void sort(Comparable[]tab){
		int m=0;
		for (int i=0; i<tab.length; i++){               /*Parcourir le tableau*/
			for(int j=1; tab[j].compareTo(tab[i])<0; j++){   /*Trouver la place où il faut insérer*/
				m=j;
			}
			tab[m]=tab[i];                      /*Recopier l'élément à inséréer*/
			for(int k=i; k>m; k--){
				tab[k]=tab[k-1];
			}
		}
 
	}
Mais j'ai un problème dans mon programme. Pouvez vous m'aider svp?
Merci