Ajout de recherche IUT(compile mais à tester et vérifier) 15/12 11h42

master
Sami GHEBRID 2 years ago
parent 5859d9606d
commit 2a698e94bc

@ -35,4 +35,68 @@ void clearpage(void)
printf("\nappuyé sur la touche [ENTREE] pour continuer"); printf("\nappuyé sur la touche [ENTREE] pour continuer");
scanf("%*c%c", &entre); scanf("%*c%c", &entre);
system("clear"); system("clear");
} }
int chargement(VilleIUT *tiut[],int *tMax)
{
FILE *flot;
VilleIUT *v;
MaillonDept *m;
int nb = 0, pos;
char trouve;
flot = fopen("IUT.don", "r");
if(flot == NULL)
{
printf("Problème d'ouverture du fichier\n");
return -1;
}
while(!feof(flot))
{
v = (VilleIUT *)malloc(sizeof(VilleIUT));
if(v == NULL)
{
printf("Problème allocation ville lors de la lecture du fichier\n");
return -2;
}
fscanf(flot, "%s", v->nom);
pos = recherche(tiut, nb, v->nom, &trouve);
m = (MaillonDept *)malloc(sizeof(MaillonDept));
if(m == NULL)
{
printf("Problème allocation département lors de la lecture du fichier\n");
return -3;
}
*m = lireDep(flot);
if(trouve == 'O')
{
insererDep(tiut[pos],*m);
}
else
{
m->suiv = NULL;
v->lDept = m;
tiut[nb] = v;
}
free(v);
free(m);
nb++;
}
return nb;
}
int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], char *trouve){
int inf,sup,t;
inf=0;
sup=tLog-1;
while(inf<=sup){
t=(inf+sup)/2;
if(strcmp(ville,tiut[t]->nom)==0){
*trouve=1;
return t;
}
if(strcmp(ville,tiut[t]->nom)<0)
sup=t-1;
else inf=t+1;
}
}

@ -3,11 +3,6 @@
#include<string.h> #include<string.h>
#include<stdbool.h> #include<stdbool.h>
//################ Fonction Menu #####################
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax);
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax);
//################ Types de structures ############### //################ Types de structures ###############
typedef struct maillonDept typedef struct maillonDept
@ -29,9 +24,11 @@ typedef struct
//################ Fonctions communes ################# //################ Fonctions communes #################
void clearpage(void); void clearpage(void);
int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], char *trouve);
//################ Fonction Menu #####################
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax);
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax);

@ -2,4 +2,5 @@
int main(void){ int main(void){
return 0;
} }
Loading…
Cancel
Save