********************************************************************************************* #include<stdio.h> #include<stdlib.h> #include <string.h> typedef struct dictionaire { char motfrancais[20]; char motanglais[20]; dictionaire *sag; dictionaire *sad; }dictionaire; void creer_arbredictionaire(dictionaire *&r); void afficherin_ordre(dictionaire*&r); char recherche_un_mots(dictionaire *&r); void ajouter_mots (dictionaire *&r); void traduire_texte(dictionaire *&r); dictionaire*r; char phrase [50];char fr[20];char an [50];char x[20];char y[20];char z[20];char w[20];char e[20];char k[20];char g[20]; int m,n,i,j,l; int main() {i=1; system("\ncolor fc"); do { printf(" *******************************************************************************\n"); printf(" * Bienvenue sur le dictionnaire francais/anglais *\n"); printf(" *******************************************************************************\n"); printf(" \n entrez votre chois: \n"); printf("0- recherche un mot dans le dictionaire\n"); printf("1- creer le dictionaire\n"); printf("2-afficher les mots de dictionaire \n"); printf("3-ajouter un mots dans le dictionaire \n"); printf("4-traduire un texte \n"); printf("5-pour quitter \n"); scanf("%d",&m); switch (m) { case 1 : printf("\n donner la taille de l'arbre : "); scanf("%d",&n); r=NULL; for(i=0;i<n;i++) { printf("\n donner le mots en francais : "); scanf("%s",&fr); printf("\n donner le mots en anglais : "); scanf("%s",&an); creer_arbredictionaire(r); } break; case 2 :afficherin_ordre(r);break; case 3 : printf("\n donner le mots en francais que vous ajoute : "); scanf("%s",&fr); printf("\n donner le mots en anglais que vous ajoute : "); scanf("%s",&an); ajouter_mots (r); break; case 0 : printf("\n donner le mots en francais que vous chercher dans le dictionare : "); scanf("%s",&fr); recherche_un_mots(r); break; case 4 : printf("\n donner le texte en francais que vous dans traduire : "); scanf("%s",& phrase ); traduire_texte(r) ;break; case 5 :break; } }while (n!=5); system("\npause"); scanf("%d"); return 0; } /***************************procedure creer_arbredictionaire**************************************/ void creer_arbredictionaire(dictionaire *&r) { if(r==NULL) { r=(dictionaire*)malloc(sizeof(dictionaire)); strcpy(r->motfrancais,fr); strcpy(r->motanglais,an); r->sag=NULL; r->sad=NULL; } else { if(strcmp(fr,r->motfrancais)<0) { creer_arbredictionaire(r->sag); } else { if(strcmp(fr,r->motfrancais)>0) { creer_arbredictionaire(r->sad); } else printf("\n le mots deja existe ."); } } } /***************************procedureafficherin_ordre**************************************/ void afficherin_ordre(dictionaire*&r) { if(r!=NULL) { afficherin_ordre(r->sag); printf(" \n les mots de dictionaire est : %s = %s",r->motfrancais,r->motanglais); afficherin_ordre(r->sad); } printf(" \n "); } /***************************procedure ajouter_mots **************************************/ void ajouter_mots (dictionaire *&r) { if(r==NULL) { r=(dictionaire*)malloc(sizeof(dictionaire)); strcpy(r->motfrancais,fr); strcpy(r->motanglais,an); r->sag=NULL; r->sad=NULL; } else { if(strcmp(fr,r->motfrancais)<0) { creer_arbredictionaire(r->sag); } else { if(strcmp(fr,r->motfrancais)>0) { creer_arbredictionaire(r->sad); } else printf("\n le mots deja existe ."); } } } /***************************procedure recherche_un_mots **************************************/ char recherche_un_mots(dictionaire *&r) { if(r==NULL) printf("\n ?"); else { if(strcmp(fr,r->motfrancais)<0) recherche_un_mots(r->sag); else { if(strcmp(fr,r->motfrancais)>0) recherche_un_mots(r->sad); else printf("c element est appartient a cette arbre et le sens de mot est: .\n "); strcpy(x,r->motanglais); printf(" %s",x); } } } /***************************procedure traduire_texte**************************************/ void traduire_texte(dictionaire *&r ) { j=0; l=strlen(phrase); strcpy(z, " "); strcpy(w, ","); strcpy(e, "."); for (i=0;i<l;i++) { g[0]=phrase[i]; if ((strcmp(g,z)<0)&&(strcmp(g,w)<0)&&(strcmp(g,e)<0)) { k[j]= phrase[i]; j=j+1; } strcpy(fr,k); recherche_un_mots(r); j=0; } } *********************************************************************************************
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include<stdio.h> #include<stdlib.h> #include <string.h> typedef struct dictionaire { char motfrancais[20]; char motanglais[20]; dictionaire *sag; dictionaire *sad; }dictionaire; void creer_arbredictionaire(dictionaire *&r); void afficherin_ordre(dictionaire*&r); char recherche_un_mots(dictionaire *&r,char fr[20]); void ajouter_mots (dictionaire *&r); void traduire_texte(dictionaire *&r,char phrase [50]); dictionaire*r; char phrase [50];char fr[100];char an [50]; char y[20];char z[20];char w[20];char e[20];char g[20];char t[20]; int m,n,i,j,l,b,x; int main() {i=0; system("\ncolor ac"); do { printf(" *******************************************************************************\n"); printf(" * Bienvenue sur le dictionnaire francais/anglais *\n"); printf(" *******************************************************************************\n"); printf(" \n entrez votre chois: \n"); printf("0- recherche un mot dans le dictionaire\n"); printf("1- creer le dictionaire\n"); printf("2-afficher les mots de dictionaire \n"); printf("3-ajouter un mots dans le dictionaire \n"); printf("4-traduire un texte \n"); printf("5-pour quitter \n"); scanf("%d",&m); switch (m) { case 1 : printf("\n donner la taille de l'arbre : "); scanf("%d",&n); r=NULL; for(i=0;i<n;i++) { printf("\n donner le mots en francais : "); scanf("%s",&fr); printf("\n donner le mots en anglais : "); scanf("%s",&an); creer_arbredictionaire(r); } break; case 2 :afficherin_ordre(r);break; case 3 : printf("\n donner le mots en francais que vous ajoute : "); scanf("%s",&fr); printf("\n donner le mots en anglais que vous ajoute : "); scanf("%s",&an); ajouter_mots (r); break; case 0 : printf("\n donner le mots en francais que vous chercher dans le dictionare : "); scanf("%s",&fr); recherche_un_mots(r,fr); break; case 4 : printf("\n donner le texte en francais que vous dans traduire : "); scanf("%s",& phrase ); traduire_texte(r, phrase) ;break; case 5 :break; } }while (n!=5); system("\npause"); scanf("%d"); return 0; } /***************************procedure creer_arbredictionaire**************************************/ void creer_arbredictionaire(dictionaire *&r) { if(r==NULL) { r=(dictionaire*)malloc(sizeof(dictionaire)); strcpy(r->motfrancais,fr); strcpy(r->motanglais,an); r->sag=NULL; r->sad=NULL; } else { if(strcmp(fr,r->motfrancais)<0) { creer_arbredictionaire(r->sag); } else { if(strcmp(fr,r->motfrancais)>0) { creer_arbredictionaire(r->sad); } else printf("\n le mots deja existe ."); } } } /***************************procedureafficherin_ordre**************************************/ void afficherin_ordre(dictionaire*&r) { if(r!=NULL) { afficherin_ordre(r->sag); printf(" \n les mots de dictionaire est : %s = %s",r->motfrancais,r->motanglais); afficherin_ordre(r->sad); } printf(" \n "); } /***************************procedure ajouter_mots **************************************/ void ajouter_mots (dictionaire *&r) { if(r==NULL) { r=(dictionaire*)malloc(sizeof(dictionaire)); strcpy(r->motfrancais,fr); strcpy(r->motanglais,an); r->sag=NULL; r->sad=NULL; } else { if(strcmp(fr,r->motfrancais)<0) { creer_arbredictionaire(r->sag); } else { if(strcmp(fr,r->motfrancais)>0) { creer_arbredictionaire(r->sad); } else printf("\n le mots deja existe ."); } } } /***************************procedure recherche_un_mots **************************************/ char recherche_un_mots(dictionaire *&r,char fr[100]) { if(r!=NULL) { if(strcmp(fr,r->motfrancais)<0) recherche_un_mots(r->sag,fr); else { if(strcmp(fr,r->motfrancais)>0) recherche_un_mots(r->sad,fr); else { printf(" %s",r->motanglais); } } } else printf("\n ?"); } /***************************procedure traduire_texte**************************************/ void traduire_texte(dictionaire *&r,char phrase [50] ) { char k[20]; for (x=0; x<=20; x++) { k[x]=t[0]; } j=0; l=strlen(phrase)-1; strcpy(z, " "); strcpy(w, ","); strcpy(e, "."); strcpy(t, "\0"); for( i=0;i<=l;i++) { g[0]=phrase[i]; if ((strcmp(g,z)!=0)&&(strcmp(g,w)!=0)&&(strcmp(g,e)!=0)) { k[j]=phrase[i]; j=j+1; } else { b=strlen(k); recherche_un_mots(r,k); j=0; for (x=0; x<= b; x++) { k[x]=t[0]; } } } recherche_un_mots(r,k); }