Documente Academic
Documente Profesional
Documente Cultură
} float totalSalaire(ListEmp l)
void saisirListEmployes(ListEmp *l, int n) {
{ float total=0;
int i; noeud *p=l.tete;
Employe E; while(p!=NULL)
l->tete=NULL; {
for(i=1;i<=n;i++) total+=salaireEmploye(p->valeur);
{ p=p->suivant;
printf("saisir l'employe %d\n", i); }
saisirEmploye(&E); return total;
ajouterEmploye(l, E); }
} void main()
} {
void affichListEmployes(ListEmp l) ListEmp l;
{ int i,n;
noeud *p=l.tete; printf("combien d'employes ?");
while(p!=NULL) scanf("%d", &n);
{ saisirListEmployes(&l, n);
affichEmploye(p->valeur); printf("voici la liste des employes\n");
p=p->suivant; affichListEmployes(l);
} printf("salaire total=%f\n", totalSalaire(l));
} }
Module : Atelier de Programmation Avancée Correction TD/TP N° 3 : Les listes chainées
Correction proposée par Mme Saloua Guezguez Sections : SI1-TRC1
Exercice 3 p=p->suivant;
typedef struct p->suivant=nouveau;
{ }
char nom[30]; }
int rdv; void rendezVous (SalleDattente s, int *rdv, int *sansRdv)
}Patient; {
typedef struct noeud noeud *p=s.tete;
{ *rdv=0;
Patient valeur; *sansRdv=0;
struct noeud *suivant; while(p!=NULL)
}noeud; {
typedef struct if(p->valeur.rdv==1)
{ (*rdv)++;
noeud *tete; else
}SalleDattente; (*sansRdv)++;
void ajouterPatient(SalleDattente *s, Patient pat) p=p->suivant;
{ }
noeud *p, *nouveau; }
nouveau=(noeud*)malloc(sizeof(noeud));
nouveau->valeur=pat;
nouveau->suivant=NULL;
if(s->tete==NULL)
s->tete=nouveau;
else
{
p=s->tete;
while(p->suivant!=NULL)
Module : Atelier de Programmation Avancée Correction TD/TP N° 3 : Les listes chainées
Correction proposée par Mme Saloua Guezguez Sections : SI1-TRC1