Tri File (liste chainee)

ANONYM -  
lami20j Messages postés 21644 Statut Modérateur, Contributeur sécurité -
Bonjour,
j'ais une file (liste simplement chainée) de candidats, chaque candidats est identifié par un nom, prenom, genre et un score. je veux ecrire une fonction qui permet de trier cette liste dans l'ordre decroissant pouvez vous m'aider svp! voila un bout du code :

typedef struct candidat 
{ 
  char nom[20]; 
  char prenom[20]; 
  char genre; 
  float score; 
  struct candidat *suivant; 
}candidat; 

typedef struct file 
{ 
  candidat *debut; 
  candidat *fin; 
  int taille; 
}file; 

void enfiler(file *f, char n[20], char pn[20], char g, float s) 
{ 
candidat *c=(candidat*)malloc(sizeof(candidat)); 
strcpy(c->nom,n); strcpy(c->prenom,pn); 
c->genre = g; c->score = s; 
c->suivant = NULL; 
if (f->fin!=NULL) { f->fin->suivant = c; f->fin = c; } else { f->debut = c; f->fin = c; } 
f->taille++; 
printf("*** candidat %d enregistre ***\n\n",f->taille); 
} 


merci d'avance!
A voir également:

1 réponse

lami20j Messages postés 21644 Statut Modérateur, Contributeur sécurité 3 570
 
0