#include "dictionnary.c" #define FILE_SIZE 2030 static Tree dictionnary; char is_small_letter(char c) { return ('a' <= c) && (c <= 'z'); } char is_letter(char c) { return (('A' <= c) && (c <= 'Z')) || is_small_letter(c); } char to_upper(char c) { if ( is_small_letter(c) ) return 'A' - 'a' + c; return c; } void upper_str(char *str) { while (*str) { *str=to_upper(*str); } } char contains_english(char *decoded, int length) { int i; char tmpword[FILE_SIZE]; int maxwordlen=0; int len=0; int badlen=0; int w=0; int nb_english_word=0; for (i=0; i5) { fprintf(stderr,"%s\n",tmpword); } if (is_element(dictionnary,tmpword)) { fprintf(stderr,"WORD: %s\n",tmpword); nb_english_word++; } w=0; } } return nb_english_word > 0; } void decode(char *src, char *decoded, int code[], int length) { int i,j; for (i=0,j=0;i %s\n", tst_str); for (i='z'; i>='a'; i--) { fprintf(stderr,"\n%c: ", i); code[0]=i; for (j='a'; j<='z'; j++) { code[1]=j; for (k='a'; k<='z'; k++) { code[2]=k; decode(src,decoded,code,length); if (contains_english(decoded, length)) { printf("\ncode = %c,%c,%c", code[0],code[1],code[2]); printf("decoded message: %s",decoded); printf("Sum = ", sum(decoded)); } } } } return 0; }