Débuggage et changement de structure avec adaptation dans toutes les fonctions. Tout compile et fonctionne
parent
fb8d334666
commit
ad68a43e68
@ -1,94 +1,101 @@
|
||||
#include "Jsae.h"
|
||||
|
||||
ListeDept listenouv(void){
|
||||
Liste d;
|
||||
d=NULL;
|
||||
return d;
|
||||
ListeDept listeDeptNouv(void)
|
||||
{
|
||||
ListeDept lDept;
|
||||
lDept = NULL;
|
||||
return lDept;
|
||||
}
|
||||
|
||||
ListeDept InsérerEntete(ListeDept d,int nb){
|
||||
ListeDept insérerEntete(ListeDept lDept,Departement d)
|
||||
{
|
||||
MaillonDept *m;
|
||||
m=(MaillonDept*)malloc(sizeof(Maillon));
|
||||
if(m==NULL){
|
||||
printf("pb malloc\n");
|
||||
m = (MaillonDept *)malloc(sizeof(MaillonDept));
|
||||
if(m == NULL)
|
||||
{
|
||||
printf("Problème d'allocation mémoire lors de l'insertion\n");
|
||||
exit(1);
|
||||
}
|
||||
m->v=x;
|
||||
m->suiv=l;
|
||||
m->d = d;
|
||||
m->suiv = lDept;
|
||||
return m;
|
||||
}
|
||||
|
||||
Liste Insérer(Liste l, int x){
|
||||
if(l==NULL)
|
||||
return InsérerEntete(l,x);
|
||||
if(x<l->suiv)
|
||||
return InsérerEntete(l,x);
|
||||
if(x==l->v)
|
||||
return l;
|
||||
l->suiv=Insérer(l->suiv,x);
|
||||
return l;
|
||||
ListeDept insérerDept(ListeDept lDept, Departement d)
|
||||
{
|
||||
if(lDept == NULL)
|
||||
return insérerEntete(lDept,d);
|
||||
if(d.dept < lDept->d.dept)
|
||||
return insérerEntete(lDept,d);
|
||||
if(d.dept == lDept->d.dept)
|
||||
printf("Département déjà présent dans cet IUT\n");
|
||||
return lDept;
|
||||
lDept->suiv = insérerDept(lDept->suiv,d);
|
||||
return lDept;
|
||||
}
|
||||
|
||||
Liste supprimerEntete(Liste l){
|
||||
Maillon *aux;
|
||||
if(l==NULL){
|
||||
ListeDept supprimerEntete(ListeDept lDept)
|
||||
{
|
||||
ListeDept aux;
|
||||
if(lDept == NULL)
|
||||
{
|
||||
printf("Opération interdite\n");
|
||||
exit(1);
|
||||
}
|
||||
aux=l;
|
||||
l=l->suiv;
|
||||
aux = lDept;
|
||||
lDept = lDept->suiv;
|
||||
free(aux);
|
||||
return l;
|
||||
return lDept;
|
||||
}
|
||||
|
||||
Liste supprimer(Liste l, int x){
|
||||
if(l==NULL)
|
||||
return l;
|
||||
if(x<l->v)
|
||||
return l;
|
||||
if(x==l->v)
|
||||
return supprimerEntete(l);
|
||||
l->suiv=supprimer(l->v,x);
|
||||
return l;
|
||||
ListeDept supprimerDept(ListeDept lDept, Departement d)
|
||||
{
|
||||
if(lDept == NULL)
|
||||
return lDept;
|
||||
if(d.dept < lDept->d.dept)
|
||||
return lDept;
|
||||
if(d.dept == lDept->d.dept)
|
||||
return supprimerEntete(lDept);
|
||||
lDept->suiv = supprimerDept(lDept->suiv,d);
|
||||
return lDept;
|
||||
}
|
||||
|
||||
int longueur(Liste l){
|
||||
int cpt=0;
|
||||
while(l!=NULL){
|
||||
cpt=cpt+1;
|
||||
l=l->suiv;
|
||||
int longueur(ListeDept lDept)
|
||||
{
|
||||
int compt = 0;
|
||||
while(lDept != NULL)
|
||||
{
|
||||
compt = compt + 1;
|
||||
lDept = lDept->suiv;
|
||||
}
|
||||
return cpt;
|
||||
return compt;
|
||||
}
|
||||
|
||||
bool vide(Liste l){
|
||||
if(l==NULL)
|
||||
bool vide(ListeDept lDept)
|
||||
{
|
||||
if(lDept == NULL)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Liste ajouterEnqueue(Liste l, int x){
|
||||
if(vide(l))
|
||||
return InsérerEntete(l,x);
|
||||
l->suiv=ajouterEnqueue(l->suiv,x);
|
||||
return l;
|
||||
}
|
||||
|
||||
int tete(Liste l){
|
||||
/*int tete(Liste l){
|
||||
if(l==NULL){
|
||||
printf("Opération interdite\n");
|
||||
exit(1)
|
||||
}
|
||||
return l->v;
|
||||
}
|
||||
}*/
|
||||
|
||||
bool rechercher(Liste l, int x){
|
||||
if(vide(l))
|
||||
bool rechercherDept(ListeDept lDept, Departement d)
|
||||
{
|
||||
if(vide(lDept))
|
||||
return false;
|
||||
if(x<l->v)
|
||||
if(d.dept < lDept->d.dept)
|
||||
return false;
|
||||
if(x==l->v)
|
||||
if(d.dept == lDept->d.dept)
|
||||
return true;
|
||||
return rechercher(l->suiv,x);
|
||||
return rechercherDept(lDept->suiv, d);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue