int main(void) { char c; char *p = "ay"; char t[2]; int eng=0; t[0] = t[1] = '\0'; while(scanf("%c", &c) != EOF){ if(iseng(c) && eng){ printf("%c", c); } if(!iseng(c) && !eng){ printf("%c", c); } if(iseng(c) && !eng){ eng = 1; if(!ismom(c)) t[0] = c; else printf("%c", c); } if(!iseng(c) && eng){ eng = 0; printf("%s%s%c", t, p, c); t[0] = '\0'; } } if(eng) printf("%s%s", t, p); return 0; }
char *strhebpatch(char *dest, const char *src) { short int mode = 0, imode; const char *hmark = NULL, *lmark, *nmark, *nlmark; char ch; const char* srcstart = src; if (src == NULL) return NULL; for (;;) { if (mode == 0) { if (isheb(*src)) { hmark = src; mode = 1; } else *dest++ = *src; } else if (mode == 1) { if (*src == 0 || iseng(*src)) { lmark = src-1; while (lmark > srcstart && !isheb(*lmark) && !ispunct(*lmark)) lmark--; src = lmark; imode = 0; nmark = NULL; while (lmark >= hmark) { ch = *lmark; if (imode == 0) switch (ch) { case '(': ch = ')'; break; case ')': ch = '('; break; case '{': ch = '}'; break; case '}': ch = '{'; break; case '[': ch = ']'; break; case ']': ch = '['; break; } if (imode == 0) { if (isdigit(ch)) { imode = 1; nmark = lmark; } else *dest++ = ch; } else if (imode == 1 && (isheb(ch) || iswhitespace(ch) || ispunct(ch))) { nlmark = lmark+1; while (nlmark <= nmark) *dest++ = *nlmark++; imode = 0; lmark++; } lmark--; } hmark = NULL; mode = 0; } if (*src == '\0') *dest = '\0'; } if (!*src++) break; } return dest; }