bugs.cpp
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cctype>
size_t mygets (char *out)
{
int c;
char *pout = out;
while ((c = getchar ()) != '\n')
*pout++ = c;
*pout = '\0';
return pout - out;
}
int main ()
{
int line_no;
while (scanf ("%d", &line_no) == 1)
{
int c;
getchar ();
static char marker[1001] = {0};
char *pmarker = marker;
while ((c = getchar ()) != '\n')
if (isalpha (c))
*pmarker++ = c;
*pmarker = '\0';
size_t marker_len = pmarker - marker;
while (line_no--)
{
static char line[2000001] = {0};
char *pline = line;
size_t line_len = mygets (line) + 1;
char *pbug;
while ((pbug = strstr (pline, marker)))
{
line_len -= marker_len;
memmove (pbug, pbug + marker_len, line_len - (pbug - line));
pline = pbug - marker_len;
if (pline < line)
pline = line;
}
puts (line);
}
}
return 0;
}