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
|
// declaration de la chaine
typedef struct lista
{
char stringa[9];
struct lista *next;
}list;
// les mots sont memorisés dans une matrice mat
}
int main(int agrc, char *argv[])
{
list *tete;
tete=NULL;
list *nouveau,*courant;
int i,trouver=0//variable d'aide;
for(i=0;i<l;i++)
{
if(tete==NULL)
{
nouveau=(list *)malloc(sizeof(list));
if(nouveau==NULL)
{// ajout en tete de la liste
printf(stderr,"erreur allocation memoire");
return EXIT_FAILURE;
}
strcpy(nouveau->stringa,mat[i]);
nouveau->next=tete;
tete=nouveau;
}
else
{
courant= tete;
if(strcmp(courant->stringa,mot[i])==0)
trouver=1;
while(courant->next!=null)
{
courant=courant->next;
if(strcmp(courant->stringa,mot[i])==0)
trouver=1;
}
if(trouver==0)
{ /*ca veut dire qu'on n'a pas trouve un elemetn qui se repetent donc on peut inserer mat[i]*/
strcpy(nouveau->stringa,mat[i]);
nouveau->next=null;
courant->next=nouveau;
}
}
}
} |
Partager