Yûki - Update Insert (not working)
This commit is contained in:
parent
742877f86b
commit
6a10f640c3
2 changed files with 29 additions and 15 deletions
|
|
@ -20,18 +20,31 @@ Freq ajouter(int nb, int lettre, Freq l){
|
|||
}
|
||||
|
||||
Freq inserer(int nb, int lettre, Freq l){
|
||||
Occ *tmp = l;
|
||||
printf("Inserer :\n");
|
||||
if(est_liste_vide(l)){
|
||||
printf("Liste vide :\n");
|
||||
return ajouter(nb,lettre,creer_liste_vide());
|
||||
}
|
||||
else{
|
||||
Freq new;
|
||||
while(nb>tete_freq(l)){
|
||||
new=ajouter(nb,lettre,queue(tmp));
|
||||
printf("Liste non vide :\n");
|
||||
Occ * tmp;
|
||||
tmp = NULL;
|
||||
Freq new,csl,elem;
|
||||
new = l;
|
||||
elem->nb=nb;
|
||||
elem->lettre=lettre;
|
||||
printf("Boucle : freq : \n",tete_freq(new));
|
||||
while( new && tete_freq(new)<nb){
|
||||
printf("nb: %d / freq : %d \n",nb,tete_freq(new));
|
||||
tmp=new;
|
||||
new = queue(new);
|
||||
}
|
||||
tmp->suiv=new;
|
||||
printf("Fin boucle :\n");
|
||||
elem->suiv=csl;
|
||||
tmp->suiv=elem;
|
||||
return tmp;
|
||||
}
|
||||
return l;
|
||||
|
||||
}
|
||||
|
||||
int tete_lettre(Freq l){
|
||||
|
|
@ -83,11 +96,11 @@ Freq incrementer(int lettre, Freq l){
|
|||
if(est_liste_vide(l)){
|
||||
return l;
|
||||
}
|
||||
else if(lettre == tete_lettre(l)){
|
||||
else{
|
||||
while(lettre != tete_lettre(l)){
|
||||
l=queue(l);
|
||||
}
|
||||
l->nb++;
|
||||
return l;
|
||||
}
|
||||
else{
|
||||
return incrementer(lettre,queue(l));
|
||||
}
|
||||
}
|
||||
|
|
@ -40,11 +40,10 @@ int main(int argc, char **argv){
|
|||
arbre huff;
|
||||
huff = huffman(creer_arbre_vide(),freq);
|
||||
printf("FIN Test Huffman\n");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Freq freq_apparition(FILE *file){
|
||||
Freq text;
|
||||
text = creer_liste_vide();
|
||||
|
|
@ -75,7 +74,7 @@ arbre huffman(arbre H, Freq L){
|
|||
int i;
|
||||
i=0;
|
||||
while((L->suiv != NULL)||i<50){
|
||||
printf("%d \n",i++);
|
||||
printf("Test n°%d \n",i++);
|
||||
int al,bl,ap,bp;
|
||||
al = tete_lettre(L);
|
||||
ap = tete_freq(L);
|
||||
|
|
@ -86,8 +85,10 @@ arbre huffman(arbre H, Freq L){
|
|||
arbre fg,fd;
|
||||
fg=creer_feuille(al,ap);
|
||||
fd=creer_feuille(bl,bp);
|
||||
H=creer_arbre_huffman(al*100+ap,ap+bp,fg,fd);
|
||||
L=inserer(ap+bp,al*100+bl,L);
|
||||
H=creer_arbre_huffman(0,ap+bp,fg,fd);
|
||||
printf("Test insérer\n");
|
||||
L=inserer(ap+bp,0,L);
|
||||
printf("Affichage vérification\n");
|
||||
l=L;
|
||||
while(!est_liste_vide(l)){
|
||||
printf("%d (%d)\n",tete_lettre(l),tete_freq(l));
|
||||
|
|
|
|||
Reference in a new issue