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 34 35 36 37 38 39 40 41 42 43
| #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<time.h>
int main()
{
char ch[27],mot[27];
char m[5000][27];//matrice dont je stock les mots du dictioonnaire qui peuvent etre former par ch
int i=0;
printf("donner une chaine \n");
gets(ch);
FILE* f=NULL;
f=fopen("dictionnaire.txt","r");
while(fgets(mot,27,f)!=NULL)
{
int j=0,erreur=0;//erreur variable bool intitialisé à 0 si une lettre du mot n'exite pas dans ch elle prend 1
while(j<strlen(mot)&& erreur==0)
{
if(strchr(ch,mot[j])!=NULL)
j++;
else
erreur=1;
}
if(!(erreur))
{
strcpy(m[i],mot);
i++;
}
}
fclose(f);
int n=i;
for(i=0;i<n;i++)
printf("%s\n",m[i]);
return 0;
system("pause");
} |
Partager