Giz |
chrisbk a écrit a écrit :
tu te fais un tableau annexe :
int indiceTab[10];
for (int i=0;i<10;i++)
indiceTab[i] = i;
ca c la phase 1
ensuite tu tri ton tableau tab, mais lors de tri quand tu change un element de place tu modifie aussi le tableau indiceTab
par ex :
int tab[10]={10,5,30,15,20,4,51,34,3,1} mettons apres un debut de tri tu auras :
int tab[10]={30,5,10,15,20,4,51,34,3,1} alors indiceTab doit etre :
{2,1,0,3,4,5,6,7,8,9}
et vala a fin du tri t'as plus qu'a rechope les 5 premieres entree de indiceTab
|
Ok...ton IndiceTab[10] sera = à : {0,1,2,3,4,5,6,7,8,9}
ensuite si je tri mon tableau de départ par ordre croissant, je PERD tout mes indices!...je ne vois pas comment tu fais. |