diff --git a/SAE.c b/SAE.c index a86a8f2..e5f8f9f 100644 --- a/SAE.c +++ b/SAE.c @@ -215,6 +215,8 @@ void global(void) tab = chargmentCandid("candidature.txt", &tphys, &nb); system("clear"); afficherCandid(tab, nb); + supprimerCandid(tab, &nb); + afficherCandid(tab, nb); } @@ -844,9 +846,103 @@ ChoixDept *traiterCandidDept(int tailleL, int tailleP, FILE *flot) return cD; } +int rechCandid(Candidat **tab, int nbEle, int id, int *trouve) +{ + int i; + for (i=0; i < nbEle; i++) + { + if (tab[i]->id == id) + { + *trouve = 1; + return i; + } + if (tab[i]->id > id) + { + *trouve = 0; + return i; + } + } +} + +void triEchangecandid(Candidat **tab, int nbEle) +{ + int pge; + while(nbEle > 1) + { + pge = plusGrandCandid(tab, nbEle); + echangerCandid(tab, pge, nbEle - 1); + nbEle = nbEle - 1; + } +} + +int plusGrandCandid(Candidat **tab, int nbEle) +{ + int pge = 0, i; + for (i = 1; i < nbEle; i++) + { + if(tab[i]->id > tab[pge]->id) + pge = 1; + return pge; + } +} + +void echangerCandid(Candidat **tab, int i, int j) +{ + Candidat *aux; + aux = tab[i]; + tab[i] = tab[j]; + tab[j] = aux; +} + +ListeCandid rechCandidIUT(ListeCandid l, char *code) +[ + if (l == NULL) + return NULL; + if ((strcmp(code, l->iutCandid)) < 0) + return NULL; + if ((strcmp(code, l->iutCandid)) == 0) + return l; + return rechCandidIUT(l->suiv, code) +] + void supprimerCandid(Candidat **tab, int *nbEle) { - int idSup; - printf("Identifiant de la candidiature à supprimer : "); - scan + int idSup, pos, trouve; + while(1) + { + printf("Identifiant de la candidiature à supprimer : "); + scanf("%d", &idSup); + pos = rechCandid(tab, *nbEle, idSup, &trouve); + if (trouve == 0) + { + printf("Candidature non présente dans la base de donnée\n"); + break; + } + if (trouve == 1) + if (!confirmationSup()) + return; + while(tab[pos]->idCandIUT != NULL) + { + suppressionCandid(tab[pos]->idCandIUT, tab[pos]->idCandIUT->iutCandid, tab[pos]->idCandIUT->tabDept, tab[pos]->idCandIUT->nbChoix); + tab[pos]->idCandIUT = tab[pos]->idCandIUT->suiv; + } + *nbEle = *nbEle - 1; + free(tab[pos]); + triEchangecandid(tab, *nbEle + 1); + + if(!verifSelection()) + return; + } +} + +void créationCandid(Candidat **tab, int *nbEle, int tailleP) +{ + char nom[30], prenom[30], dept[30], ville[30]; + int idAdd, nbDept, deciCandid, deciDept; + while(1) + { + idAdd = *nbEle; + printf("votre"); + } + } \ No newline at end of file diff --git a/SAE.h b/SAE.h index 5d80234..b201c50 100644 --- a/SAE.h +++ b/SAE.h @@ -144,8 +144,6 @@ void echangerCandidDept(ChoixDept **tDept, int i, int j); void triEchangeCandidDept(ChoixDept **tDept, int tailleL); -ChoixDept ** insererTDept(ChoixDept **tDept, int tailleP, int tailleL ,char dept[], int deciDept, int deciCandid); - void videTabDept(ChoixDept **tDept, int tailleP); ListeCandid suppressionEnTeteCandid(ListeCandid l , ChoixDept **tDept, int tailleP); @@ -166,4 +164,16 @@ Candidat lireCandidat(FILE *flot); ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot); -ChoixDept *traiterCandidDept(int tailleL, int tailleP, FILE *flot); \ No newline at end of file +ChoixDept *traiterCandidDept(int tailleL, int tailleP, FILE *flot); + +int rechCandid(Candidat **tab, int nbEle, int id, int *trouve); + +void triEchangecandid(Candidat **tab, int nbEle); + +int plusGrandCandid(Candidat **tab, int nbEle); + +void echangerCandid(Candidat **tab, int i, int j); + +ListeCandid rechCandidIUT(ListeCandid l, char *code); + +void supprimerCandid(Candidat **tab, int *nbEle); \ No newline at end of file