diff --git a/sae1-02.c b/sae1-02.c index 88991a7..92786e0 100644 --- a/sae1-02.c +++ b/sae1-02.c @@ -31,42 +31,21 @@ VilleIUT lire(FILE * fe) { // Partie 2 /* - ( beaucoup de donnée a traité n(min 10 ; max ?)*nb candidat donc faire attention ) - possibilité pour le candidat pouvoir - - - - nb candidats (général en haut du doss) - - - num candidat - - nom candidat - - prénom candidat - - liste des notes (moyenne dans le sens précis -- math francais anglais et matière spé) - |<= nb choix - |=>recurrence : - |- ville - |- département |- décision ( admis - 1 /attente 0 default /refusé -2 ) |- validation candidat ( 0 default / -1 refus de ce choix / 2 accepte ) -doit venir du menu car sinon pas de transport pour la part 3, -le tableau de pointeur qui contient listcandinfo et listcand, - - - - combien de fonctionnalité en combien de fonction ... V charger fichier + V ajouter choix - modifier choix - - ajouter choix - supp choix - V afficher les infos d'un cand - - tout cand d'un dep (ordre alphabétique) - - enregistrer fichier + V enregistrer fichier + - section affichage */ -//chargement =========================================================================================== +//chargement ============================================================================================ Listchoixdept listvide(void){return NULL;} @@ -108,8 +87,149 @@ int chargeretudiant(char nomFich[], listetuinfo *tetu[], int tmax){ return nbetu; } +//enregistrement ======================================================================================== + +void enregistrementcarte(FILE *fe, Maillonchoix* b){ + if(b==NULL){return;} + fprintf(fe, "%s\n%s\n%d\n%d\n", b->Ville, b->dep, b->decision, b->validation); + enregistrementcarte(fe, b.suivant, nb-1); + free(b); +} + +void enregistrementinfo(FILE *fe, listetuinfo etu){ + Listchoixdept b; + int i=0; + b = etu.carte; + fprintf(fe, "%d\n%s\n%s\n%d %d %d %d\n%d\n", etu->numeroetu, etu->nometu, etu->prenometu, etu->notes, etu->nbchoix); + enregistrementcarte(fe, b, etu.nbchoix); +} + +int enregistrementetudiant(char nomFich[], listetuinfo *tetu[], int nb){ + int i=0; + FILE *fe; + fe = fopen( nomFich, "w"); + if(fe==NULL){printf("\n");return-1;} + fprintf(fe, "%d\n", nb); + for(i=0; i affichage tville avec uniquement les dep =========== + +void affichagedep(MaillonDept* b){ + if(b==NULL){return;} + printf("%s", b->departement); + affichagedep(b.suivant); +} + +void affichageville(Maillon *tville[], int nbville){ + int i; + Listdept b; + for(i=0; iVille); + affichagedep(b); + printf("\n"); + } +} + +//========================== -fin de sous-partie + +int cherchelistcorrespond(MaillonDept* b, char choixdep[]){ + if(b==NULL){return -1} + if(strcmp(b->departement,choixdep)==0){return 1;} + return cherchelistcorrespond(b.suivant); +} + +int correspond(Maillon *tville[], int nbville, char choixville[], char choixdep[]){ + int i; + Listdept b; + for(i=0; iVille,choixville)==0){ + b = tville[i].ldept; + ok = cherchelistcorrespond(b, choixdep); + if(ok==1){return 1;} + } + } + return -1; +} + +void affichechoix(Maillon *tville[], int nbville, char choixville[], char choixdep[]){ + affichageville(tville); + printf("ville : "); + fgets(choixville, 31, stdin); + choixville[strlen(choixville)-1]='\0'; + fgets(choixdep, 31, stdin); + choixdep[strlen(choixdep)-1]='\0'; + ok = correspond(tville, nbville, choixville, choixdep); + while(ok=-1){ + affichageville(tville); + printf("ville : "); + fgets(choixville, 31, stdin); + choixville[strlen(choixville)-1]='\0'; + fgets(choixdep, 31, stdin); + choixdep[strlen(choixdep)-1]='\0'; + ok = correspond(tville, nbville, choixville, choixdep); + } +} + +int verifdoublon(char choixville[], char choixdep[], Maillonchoix* b){ + if(b==NULL){return 0;} + if(strcmp(choixville,b->Ville)==0){ + if(strcmp(choixdep,b->departement)==0){ + return -1 + } + } +} + +Listchoixdept ajoutercarte(Maillonchoix* a, char choixville, char choixdep){ + Maillonchoix* carte; + carte = (Maillonchoix*)malloc(sizeof(Maillonchoix)); + if(carte==NULL){printf("\n");exit(1);} + strcpy(carte->Ville,choixville); + strcpy(carte->departement,choixdep); + carte->decision=0; + carte->validation=0; + carte->suviant=a; + return carte; +} + +int allajoutprocess(Maillon *tville[], listetuinfo etu, int nbville){ + int i; + Listchoixdept b; + b = etu.carte; + char choixville[31], choixdep[31]; + affichechoix(tville, nbville, choixville, choixdep); + ok = verifdoublon(choixville, choixdep, b); + if(ok==0){b = ajoutercarte(b, choixville, choixdep);} + else{printf("\t< choix deja existant >\n");} +} + +//modifier ============================================================================================== + +// modification par ville ou par dep + + + + +//supprimer ============================================================================================= + +//affichage ============================================================================================= + //======================================================================================================= + + + + + + +// zone de test ============================================================================================ + //affiche uniquement les cartes (choix d'iut) void affichage(Listchoixdept c){ if(c==NULL){printf("\n");return;} @@ -144,8 +264,6 @@ void affichealletu(listetuinfo *tetu[], int nb){ } } -//========================================================================================================== - void test1(void){ listetuinfo *tetu[5000]; int nb; @@ -155,13 +273,37 @@ void test1(void){ affichealletu(tetu, nb); } - - +//========================================================================================================== // Partie 3 // Partie 4 + + + + + + + + + + + + + + + + + + + + + + + + + // Général (menu et ce qui en ai relié) /* questionadmin(){