1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| int recherche(struct Bibliotheque_noeud *bibliotheque){
//init des vaiables temporaire
mot motsCherche[3];
int i;
printf("Ecrire les mots clées a chercher \n");
for (i=0;i<3;i++){
printf("mot clé n %d :",i+1);
scanf("%s",motsCherche[i]);
}
//on utilise une variable temporelle pour ne pas changer la bibliotheque d origine
struct Bibliotheque_noeud *temp;
temp = bibliotheque;
//boucle de parcours
//parcours de chaque livre
while (temp!=NULL){
int j;
int k; k=0;
int trouve; trouve=0;
//parcours des 5 mots clés de chaque livre
while (!(trouve) && (k<5)){
j=0;
//parcours des 3 chaines entrées
while (!(trouve) && (j<3)){
if (strcmp(motsCherche[j],temp->livre->motsCle[k])==0) trouve = 1;
j++;
}
k++;
}
//affiche livre trouvé
if (trouve == 1) afficherLivre(temp->livre) |
Partager