#include #include #include struct eleve { char nom[20]; char prenom[20]; int note; }; void EmplirTableau(FILE *, struct eleve *, int); void TrierTableauAlpha(struct eleve *, int); void TrierTableauVal(struct eleve *, int); void SauverTableau(FILE *, struct eleve *, int); void main() { FILE * Liste, * ListesTriees; int NbEleves; struct eleve * tableau; Liste=fopen("liste.don","r"); if (Liste==NULL) { printf("il vous faut rentrer vos données dans le fichier \"liste.don\" ;\n" "celui-ci n'existe pas actuellement"); exit(1); } /*Lecture des données*/ fscanf(Liste,"%d",&NbEleves); tableau=(struct eleve *) malloc(NbEleves*sizeof(struct eleve)); EmplirTableau(Liste, tableau, NbEleves); fclose(Liste); /*Tri par ordre alphabétique*/ TrierTableauAlpha(tableau,NbEleves); ListesTriees=fopen("ListeTriee.res","w"); fprintf(ListesTriees,"Liste alphabétique :\n"); SauverTableau(ListesTriees,tableau,NbEleves); fclose(ListesTriees); /*Tri par ordre de mérite croissant*/ TrierTableauVal(tableau,NbEleves); ListesTriees=fopen("ListeTriee.res","a"); fprintf(ListesTriees,"Liste par notes croissantes :\n"); SauverTableau(ListesTriees,tableau,NbEleves); fclose(ListesTriees); } void EmplirTableau(FILE * fichier, struct eleve * tableau, int nombre) { int i; for (i=0;i=0)&& (strcmp(cle.nom,tableau[j].nom)<0);j--)tableau[j+1]=tableau[j]; tableau[j+1]=cle; } } void TrierTableauVal(struct eleve *tableau, int nombre) { int i,j; struct eleve cle; for (i=1;i=0)&& (cle.note