Commit 9937b044a6b734edc46c4a606c9529372f1b3135
1 parent
aa904462
vf tp
Showing
9 changed files
with
59 additions
and
7 deletions
Show diff stats
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Tp7_Struct/Donnees
... | ... | @@ -4,12 +4,6 @@ Vincent |
4 | 4 | 10 |
5 | 5 | 1997 |
6 | 6 | 0315978645 |
7 | -Perreira | |
8 | -Vitine | |
9 | -18 | |
10 | -02 | |
11 | -1992 | |
12 | -0625689715 | |
13 | 7 | Cuvelier |
14 | 8 | Achile |
15 | 9 | 24 |
... | ... | @@ -22,5 +16,18 @@ Luca |
22 | 16 | 01 |
23 | 17 | 1998 |
24 | 18 | +3306789712346 |
19 | +Perreira | |
20 | +Vitine | |
21 | +18 | |
22 | +02 | |
23 | +1992 | |
24 | +0625689715 | |
25 | +Roger | |
26 | +Billy | |
27 | +16 | |
28 | +01 | |
29 | +1997 | |
30 | +0652159784123 | |
31 | + | |
25 | 32 | |
26 | 33 | ... | ... |
Tp7_Struct/Tp7.c
... | ... | @@ -82,10 +82,48 @@ int compareDate(Date d1, Date d2){ |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | -void triBulle(Annuaire annuaire){ | |
85 | + | |
86 | +int rechDicho(char nomPers[], Annuaire annuaire){ | |
87 | + int debut, fin, milieu, trouve,ind; | |
88 | + fin = annuaire.dernier; | |
89 | + debut = 0; | |
90 | + trouve = 0; | |
91 | + ind=-1; | |
92 | + | |
93 | + while ( fin >= debut && trouve == 0){ | |
94 | + milieu = (debut+fin)/2; | |
95 | + if(strcmp(nomPers, annuaire.listePers[milieu].nom)==0){ | |
96 | + trouve=1; | |
97 | + ind=milieu; | |
98 | + }else if (strcmp(nomPers, annuaire.listePers[milieu].nom)<0){ | |
99 | + fin=milieu-1; | |
100 | + }else{ | |
101 | + debut=milieu+1; | |
102 | + } | |
103 | + } | |
86 | 104 | |
105 | + return ind; | |
87 | 106 | } |
88 | 107 | |
108 | +void modifTel(char nomPers[], Annuaire* annuaire, char tel[]){ | |
109 | + int res = rechDicho(nomPers,*annuaire); | |
110 | + if(res != -1){ | |
111 | + strcpy(annuaire->listePers[res].tel,tel); | |
112 | + } | |
113 | +} | |
114 | + | |
115 | +void deletePers(char nomPers[], Annuaire* annuaire){ | |
116 | + int res = rechDicho(nomPers,*annuaire); | |
117 | + if(res != -1){ | |
118 | + int i; | |
119 | + for(i=res; i <= annuaire->dernier; i++){ | |
120 | + annuaire->listePers[i]=annuaire->listePers[i+1]; | |
121 | + } | |
122 | + annuaire->dernier -= 1; | |
123 | + } | |
124 | +} | |
125 | + | |
126 | + | |
89 | 127 | |
90 | 128 | int main(){ |
91 | 129 | |
... | ... | @@ -99,6 +137,13 @@ int main(){ |
99 | 137 | Annuaire annuaire; |
100 | 138 | creerAnnuaire(&annuaire); |
101 | 139 | afficheAnnuaire(annuaire); |
140 | + | |
141 | + | |
142 | + | |
143 | + //printf("%d,%d,%d",rechDicho("Benoist",annuaire),rechDicho("Feuille",annuaire),rechDicho("Perreira",annuaire)); | |
144 | + modifTel("Benoist",&annuaire,"0320198746"); | |
145 | + deletePers("Cuvelier",&annuaire); | |
146 | + afficheAnnuaire(annuaire); | |
102 | 147 | return 1; |
103 | 148 | } |
104 | 149 | ... | ... |
Tp7_Struct/Tp7.o
No preview for this file type
Tp7_Struct/prog
No preview for this file type