diff --git a/SAE.c b/SAE.c index e5f8f9f..0567f72 100644 --- a/SAE.c +++ b/SAE.c @@ -217,7 +217,8 @@ void global(void) afficherCandid(tab, nb); supprimerCandid(tab, &nb); afficherCandid(tab, nb); - + creationCandid(tab, &nb, &tphys); + afficherCandid(tab, nb); } @@ -723,7 +724,7 @@ void afficherCandidDept(ChoixDept **tab, int nbChoix) int i; for (i=0; i < nbChoix; i++) { - printf("|%s %d %d|", tab[i]->departement, tab[i]->decisionDept, tab[i]->decisionCandid); + printf("|%s %d %d|\n", tab[i]->departement, tab[i]->decisionDept, tab[i]->decisionCandid); } } int longueur(ListeCandid l) @@ -807,7 +808,6 @@ ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot) int nbDept, i=0; ChoixDept **tDept; fscanf(flot,"%s",ville); - fscanf(flot, "%d", &nbDept); printf("%s |%d|\n", ville, nbDept); tDept = (ChoixDept **)malloc(sizeof(ChoixDept *)*(nbDept + 5)); @@ -862,6 +862,8 @@ int rechCandid(Candidat **tab, int nbEle, int id, int *trouve) return i; } } + *trouve = 0; + return nbEle - 1; } void triEchangecandid(Candidat **tab, int nbEle) @@ -881,7 +883,9 @@ int plusGrandCandid(Candidat **tab, int nbEle) for (i = 1; i < nbEle; i++) { if(tab[i]->id > tab[pge]->id) - pge = 1; + { + pge = i; + } return pge; } } @@ -895,15 +899,15 @@ void echangerCandid(Candidat **tab, int i, int j) } 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) -] + return rechCandidIUT(l->suiv, code); +} void supprimerCandid(Candidat **tab, int *nbEle) { @@ -929,20 +933,84 @@ void supprimerCandid(Candidat **tab, int *nbEle) *nbEle = *nbEle - 1; free(tab[pos]); triEchangecandid(tab, *nbEle + 1); + return; if(!verifSelection()) return; } + return; } -void créationCandid(Candidat **tab, int *nbEle, int tailleP) +Candidat **reallocTCandid(Candidat **tab, int *tailleP) { - char nom[30], prenom[30], dept[30], ville[30]; - int idAdd, nbDept, deciCandid, deciDept; + Candidat **aux; + *tailleP = *tailleP + 1; + aux = (Candidat **)realloc(tab, *tailleP * sizeof(Candidat *)); + if (aux == NULL) + { + printf("Erreur realloc\n"); + exit(1); + } + return aux; +} + +void creationCandid(Candidat **tab, int *nbEle, int *tailleP) +{ + char nom[30], prenom[30], choix[4]; + int idAdd, i; + Candidat c; + if (*nbEle == *tailleP) + tab = reallocTCandid(tab, tailleP); while(1) { - idAdd = *nbEle; - printf("votre"); + idAdd = tab[*nbEle - 1]->id + 1; + printf("Votre prénom : "); + scanf("%s%*c", prenom); + printf("Votre nom : "); + fgets(nom,30, stdin); + nom[strlen(nom) - 1] = '\0'; + printf("%s %s\n", prenom, nom); + printf("vos 4 notes : "); + scanf("%f %f %f %f", &c.note[0], &c.note[1], &c.note[2], &c.note[3]); + printf("note : |%.1f|%.1f|%.1f|%.1f|\n",c.note[0], c.note[1], c.note[2], c.note[3]); + while(1) + { + printf("vous valider votre candidature (oui|non) : "); + scanf("%s", choix); + if (strcmp(choix, "oui")==0) + { + c.id = idAdd; + strcpy(c.nom, nom); + strcpy(c.prenom, prenom); + c.idCandIUT = ListeCandidvide(); + *(tab[*nbEle]) = c; + *nbEle = *nbEle + 1; + printf("création terminer \n"); + break; + } + if (strcmp(choix, "non")==0) + break; + } + while(1) + { + printf("voulez vous faire votre choix maintenant (oui|non) : "); + scanf("%s", choix); + if (strcmp(choix, "oui")==0) + { + printf("en construction\n"); + } + if (strcmp(choix, "non")==0) + break; + } + if(!verifSelection()) + break; } - + return; +} + +void modifCandid(Candidat **tab, int nbEle) +{ + Candidat c; + printf("en construction"); + return; } \ No newline at end of file diff --git a/SAE.h b/SAE.h index b201c50..dbedf48 100644 --- a/SAE.h +++ b/SAE.h @@ -176,4 +176,10 @@ 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 +void supprimerCandid(Candidat **tab, int *nbEle); + +Candidat **reallocTCandid(Candidat **tab, int *tailleP); + +void creationCandid(Candidat **tab, int *nbEle, int *tailleP); + +void modifCandid(Candidat **tab, int nbEle); \ No newline at end of file