1 /******************************************************************************/
2 /* Hachage par chainage */
3 /******************************************************************************/
8 /* on choisit M tres petit pour tester le programme, mais en realite,
13 typedef struct cellule
{
15 struct cellule
*suivant
;
27 /* "mauvaise" fonction de hachage - juste pour tester le programme */
34 for (i
= 0; i
< M
; i
++)
39 int rechercher(element x
, t_table t
)
52 int inserer(element x
, t_table
* t
)
53 /* retourne 0 si x est deja dans la table */
56 Cellule
*p
= t
->T
[i
], *preced
= NULL
;
66 t
->T
[i
] = (Cellule
*) malloc(sizeof(Cellule
));
68 t
->T
[i
]->suivant
= NULL
;
70 preced
->suivant
= (Cellule
*) malloc(sizeof(Cellule
));
71 preced
->suivant
->valeur
= x
;
72 preced
->suivant
->suivant
= NULL
;
80 printf("%d\t", L
->valeur
);
85 void afficher(t_table t
)
90 for (i
= 0; i
< M
; i
++)
92 printf("t[%d]=\t", i
);
99 /******************************************************************************/
108 printf("%d\n", rechercher(3, t
));
109 printf("%d\n", rechercher(12, t
));
122 /*****************************************************************************
123 Etat de la table a la fin du programme
124 --------------------------------------
128 *****************************************************************************/