1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| unsigned int ChercherMotDansTableHash(Liste **TableHash,char *mot){
Liste *p;
unsigned int cle;
cle = HashCode(mot);
for(p=TableHash[cle];p!=NULL;p=p->suivant)
if(strcmp(p->m->mot,mot)==0)
return 1;
return 0;
}
unsigned int HashCode (char *ligne)
{
int i;
int Code=0;
for (i=0;i< strlen(ligne);i++)
Code=ligne[i]+31*Code;
return Code%101;
}
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "table_hash.h"
#define TAILLEHASH 307
#define NBRSEQ 10
#define SEUIL 3
#define SEUIL 3
int main()
{
FILE *F=NULL;
char mot[100];
int i,j;
unsigned int cle,pt;
int nl=1, pos=1;
//nl=pos=1;
int f;
char c;
//int seuil;
//Liste **L;
Liste *seq2=NULL;
Liste **seq;
Liste **TableHash;
TableHash = (Liste **) malloc (TAILLEHASH * sizeof(Liste *));
for(i=0;i<TAILLEHASH;++i)
TableHash[i] = NULL;
pt=HashCode(".");
//printf("%d",pt);
printf("debut du programme \n----------------------------------\n");
F=fopen("C:\\essai.txt","r");
printf("Ouverture du Fichier \n----------------------------------\n");
while(fscanf(F,"%s",mot)==1){
cle = HashCode(mot);
printf("%i", cle);
printf("-");
if ((cle!=pt ) && (!ChercherMotDansTableHash(TableHash,mot)) )
printf("fghf");
// TableHash[cle] = InsertionEnTete(TableHash[cle],mot);
/* if(fgetc(F)==EOF)
break;*/
}
fclose(F);
scanf("%s", c);
} |
Partager