From 9937b044a6b734edc46c4a606c9529372f1b3135 Mon Sep 17 00:00:00 2001 From: Vincent Benoist Date: Tue, 16 Jan 2018 17:38:44 +0100 Subject: [PATCH] vf tp --- Tp1.o | Bin 0 -> 2672 bytes Tp1_1.o | Bin 0 -> 2656 bytes Tp1_2.o | Bin 0 -> 3240 bytes Tp1_3.o | Bin 0 -> 3160 bytes Tp1_soundex.o | Bin 0 -> 2560 bytes Tp7_Struct/Donnees | 19 +++++++++++++------ Tp7_Struct/Tp7.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- Tp7_Struct/Tp7.o | Bin 3536 -> 0 bytes Tp7_Struct/prog | Bin 13096 -> 0 bytes 9 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 Tp1.o create mode 100644 Tp1_1.o create mode 100644 Tp1_2.o create mode 100644 Tp1_3.o create mode 100644 Tp1_soundex.o diff --git a/Tp1.o b/Tp1.o new file mode 100644 index 0000000..3156922 Binary files /dev/null and b/Tp1.o differ diff --git a/Tp1_1.o b/Tp1_1.o new file mode 100644 index 0000000..d18997a Binary files /dev/null and b/Tp1_1.o differ diff --git a/Tp1_2.o b/Tp1_2.o new file mode 100644 index 0000000..24df00a Binary files /dev/null and b/Tp1_2.o differ diff --git a/Tp1_3.o b/Tp1_3.o new file mode 100644 index 0000000..9da17e5 Binary files /dev/null and b/Tp1_3.o differ diff --git a/Tp1_soundex.o b/Tp1_soundex.o new file mode 100644 index 0000000..760195b Binary files /dev/null and b/Tp1_soundex.o differ diff --git a/Tp7_Struct/Donnees b/Tp7_Struct/Donnees index e76a11c..5caead7 100644 --- a/Tp7_Struct/Donnees +++ b/Tp7_Struct/Donnees @@ -4,12 +4,6 @@ Vincent 10 1997 0315978645 -Perreira -Vitine -18 -02 -1992 -0625689715 Cuvelier Achile 24 @@ -22,5 +16,18 @@ Luca 01 1998 +3306789712346 +Perreira +Vitine +18 +02 +1992 +0625689715 +Roger +Billy +16 +01 +1997 +0652159784123 + diff --git a/Tp7_Struct/Tp7.c b/Tp7_Struct/Tp7.c index 6f8e9e4..33b2da7 100644 --- a/Tp7_Struct/Tp7.c +++ b/Tp7_Struct/Tp7.c @@ -82,10 +82,48 @@ int compareDate(Date d1, Date d2){ } -void triBulle(Annuaire annuaire){ + +int rechDicho(char nomPers[], Annuaire annuaire){ + int debut, fin, milieu, trouve,ind; + fin = annuaire.dernier; + debut = 0; + trouve = 0; + ind=-1; + + while ( fin >= debut && trouve == 0){ + milieu = (debut+fin)/2; + if(strcmp(nomPers, annuaire.listePers[milieu].nom)==0){ + trouve=1; + ind=milieu; + }else if (strcmp(nomPers, annuaire.listePers[milieu].nom)<0){ + fin=milieu-1; + }else{ + debut=milieu+1; + } + } + return ind; } +void modifTel(char nomPers[], Annuaire* annuaire, char tel[]){ + int res = rechDicho(nomPers,*annuaire); + if(res != -1){ + strcpy(annuaire->listePers[res].tel,tel); + } +} + +void deletePers(char nomPers[], Annuaire* annuaire){ + int res = rechDicho(nomPers,*annuaire); + if(res != -1){ + int i; + for(i=res; i <= annuaire->dernier; i++){ + annuaire->listePers[i]=annuaire->listePers[i+1]; + } + annuaire->dernier -= 1; + } +} + + int main(){ @@ -99,6 +137,13 @@ int main(){ Annuaire annuaire; creerAnnuaire(&annuaire); afficheAnnuaire(annuaire); + + + + //printf("%d,%d,%d",rechDicho("Benoist",annuaire),rechDicho("Feuille",annuaire),rechDicho("Perreira",annuaire)); + modifTel("Benoist",&annuaire,"0320198746"); + deletePers("Cuvelier",&annuaire); + afficheAnnuaire(annuaire); return 1; } diff --git a/Tp7_Struct/Tp7.o b/Tp7_Struct/Tp7.o index 714d5d7..6191710 100644 Binary files a/Tp7_Struct/Tp7.o and b/Tp7_Struct/Tp7.o differ diff --git a/Tp7_Struct/prog b/Tp7_Struct/prog index 4c93192..b0f23d5 100755 Binary files a/Tp7_Struct/prog and b/Tp7_Struct/prog differ -- libgit2 0.21.2