parent
72ec205856
commit
2360c3d40f
@ -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(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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<string.h>
|
||||
#include<stdbool.h>
|
||||
|
||||
//################ 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);
|
Loading…
Reference in new issue