inthash(char* s){ int re = 0; for (int i = 0;s[i] && i < 3;++i) re = (s[i] - 'a')*d[i]; return re; } boolfind(char* s){ int h = hash(s); while (strcmp(s, dic[h]) > 0) ++h; if (strcmp(s, dic[h])) return0; return1; }
intmain() { freopen("in.txt", "r", stdin); memset(*dic, 0, sizeof(*dic)); char w[40], (*p)[40] = dic; while (scanf("%s", w) != -1) { int h = hash(w); while (dic[h][0]) ++h; strcpy(dic[h], w); } for (int I = 0;I < mdic;++I, ++p) { if (!*p) continue; int len = strlen(*p); for (int i = 1;i < len;++i) { char a[40], b[40]; strncpy(a, *p, i);a[i] = 0; strcpy(b, *p + i); if (find(a) && find(b)) printf("%s\n", *p); } } return0; }
v1.5.2