From 2360c3d40f00fafe06e00109405a148dfbb4ead3 Mon Sep 17 00:00:00 2001 From: Sami GHEBRID Date: Fri, 16 Dec 2022 14:54:13 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20de=20commun.c=20et=20.h=2016/12?= =?UTF-8?q?=2014h54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Commun.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Commun.h | 34 +++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 Commun.c create mode 100644 Commun.h diff --git a/Commun.c b/Commun.c new file mode 100644 index 0000000..b4377ea --- /dev/null +++ b/Commun.c @@ -0,0 +1,102 @@ + +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(xsuiv) + 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(xv) + 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(xv) + return false; + if(x==l->v) + return true; + return rechercher(l->suiv,x); +} + +Mat lireMat(FILE *fe){ + int i; + Mat m; + fscanf(fe,"%s%d%*c",&m.code,&m.coeff); + fgets(m.desig,32,fe); + m.desig[strlen(m.desig)-1]='\0'; + return m; +} + diff --git a/Commun.h b/Commun.h new file mode 100644 index 0000000..34ebbcb --- /dev/null +++ b/Commun.h @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +//################ Types de structures ############### + +typedef struct maillonDept +{ + char dept[31]; + int nbP; + char respAd[31]; + struct maillonDept *suiv; + +}MaillonDept,*ListeDept; + +typedef struct +{ + char nom[31]; + ListeDept lDept; + +}VilleIUT; + +ListeDept listenouv(void); +ListeDept InsérerEntete(ListeDept d,int nb); +Liste Insérer(Liste l, int x); +Liste supprimerEntete(Liste l); +Liste supprimer(Liste l, int x); +int longueur(Liste l); +bool vide(Liste l); +Liste ajouterEnqueue(Liste l, int x); +int tete(Liste l); +bool rechercher(Liste l, int x); +Mat lireMat(FILE *fe); \ No newline at end of file