"On ne garde que les chaînes qui ne sont pas capables d'inclure les autres chaînes."
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionvoid get_word(char **tab, const char *str) { const char* p = str; int a, i = 0; while(*str) { a = 0; while(isalpha((unsigned char) *p) && *p) p++, a = 1; if(a) tab[i++] = mstrndup(str, p-str); while(!isalpha((unsigned char) *p) && *p) p++; str = p; } } int is_in_tab(char *str, char **tab2) { while(tab2 &&*tab2) { if(!strcmp(str,*tab2)) return 1; tab2++; } return 0; } int is_contained_in(char* needle, char* heap) { get_word(); is_in_tab(); } char ** get_final_result(char** intersection) { is_contained_in( needle, heap); } int main(void) { ....... ....... char ** final_res = NULL; ..... ....... display_tab(intersect); //derniere étape final_res = get_final_result(intersect); display_tab(intersect); free_table(intersect); free_table(final_res); }
La fonction "is_contained_in" te servira dans la fonction "get_final_result". Le tableau sera parcouru à chaque fois du bas vers le haut, pour chacun des éléments, c'est en ça que la fonction "is_contained_in" te sera très utile.
int is_same2(const char *s1, const char *s2) { char **t1, **t2; size_t size1 count_word(s1), size2 count_word(s2); int ret = 0; if(size1 > size2) { t1 = malloc(size1 * sizeof(char*)); t2 = malloc(size2 * sizeof(char*)); if (t1 && t2) { size_t i, j; int a; get_word(t1, s1); get_word(t2, s2); ret = 1; for (i = 0; i < size1; i++) { a = 0; for (j = 0; j < size2; j++) if (!strcmp(t1[i], t2[j])) a = 1; if (!a) ret = 0; } free_tab(t1, size1), free_tab(t2, size2); } else exit(0); } return ret; }
//derniere étape final_res = get_final_result(intersect);
int is_in_tab(char *str, char **tab2)
void get_word(char **tab, const char *str)
Chacune des lignes du tableau intersect sont des chaînes de caractères.
Si ton ami te donne son interface graphique, c'est de la triche, non ?
Mon préféré étant QT
Load (nom du formulaire)