Académique Documents
Professionnel Documents
Culture Documents
ETAMINI Salma
GE2
Fonction de création
#include <stdio.h>
#include <stdlib.h>
struct Noeud{
int d;
struct Noeud* suivant;
};
struct Noeud* creer Noeud(int d){
struct Noeud*nouveauNoeud = (struct Noeud*)malloc(sizeof(struct Noeud));}
if(nouveauNoeud!=NULL){
nouveauNoeud->d = d;
nouveauNeoud->suivant = NULL;
}
return nouveauNoeud;
Fonction de destruction
void destruListe(struct Noeud* tete){
struct Noeud* t;
while (tete!=NULL){
t=tete;
tete=tete->suivant;
free(t);
}
Fonction d’ajout d’éléments
void ajouterelement(struct Noeud* tete, int d){
struct Noeud* nouveauNoeud = creerNoeud(d);
if(nouveauNoeud != NULL){
nouveauNoeud->suivant= *tete;
*tete = nouveauNoeud;
}
}
}
Fonction de suppression d’élément
void supprimerelement(struct Noeud* tete,int d){
}
if(cour != NULL){
if(prece != NULL){
prece->suiv = cour->suiv;
}else{
*tete = cour->suiv;
}
free(cour);
}
}
Fonction d’affichage d’élément
void affichListe(struct Noeud* tete)
while (tete != NULL){
printf("%d",tete->d);
tete = tete->suiv;
}
Fonction d’affichage et de recherche d’éléments au sein de la liste
int rechercheelement(struct Noeud* tete, int d)
while(tetet := NULL){
if(tete->d == d){
return 1;//on a trouvé l'élément
}
return 0;
}