You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
1.3 KiB
95 lines
1.3 KiB
|
|
ListeDept listenouv(void){
|
|
Liste d;
|
|
d=NULL;
|
|
return d;
|
|
}
|
|
|
|
ListeDept InsérerEntete(ListeDept d,int nb){
|
|
MaillonDept *m;
|
|
m=(MaillonDept*)malloc(sizeof(Maillon));
|
|
if(m==NULL){
|
|
printf("pb malloc\n");
|
|
exit(1);
|
|
}
|
|
m->v=x;
|
|
m->suiv=l;
|
|
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;
|
|
}
|
|
|
|
Liste supprimerEntete(Liste l){
|
|
Maillon *aux;
|
|
if(l==NULL){
|
|
printf("Opération interdite\n");
|
|
exit(1);
|
|
}
|
|
aux=l;
|
|
l=l->suiv;
|
|
free(aux);
|
|
return l;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
int longueur(Liste l){
|
|
int cpt=0;
|
|
while(l!=NULL){
|
|
cpt=cpt+1;
|
|
l=l->suiv;
|
|
}
|
|
return cpt;
|
|
}
|
|
|
|
bool vide(Liste l){
|
|
if(l==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){
|
|
if(l==NULL){
|
|
printf("Opération interdite\n");
|
|
exit(1)
|
|
}
|
|
return l->v;
|
|
}
|
|
|
|
bool rechercher(Liste l, int x){
|
|
if(vide(l))
|
|
return false;
|
|
if(x<l->v)
|
|
return false;
|
|
if(x==l->v)
|
|
return true;
|
|
return rechercher(l->suiv,x);
|
|
}
|
|
|
|
|