bugs.cpp
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
void analyseLine ( string & text, string & line )
{
string::size_type lastPos = 0;
if ( !line.length() )
{
cout << endl;
return;
}
while ( 1 )
{
lastPos = line.find ( text, lastPos );
if ( lastPos == string::npos )
{
//cout << lastPos << " " << string::npos << endl;
break;
}
line = line.erase ( lastPos, text.length() );
//cout << "PO ERASU:" << line << " pos:" << lastPos << endl;
lastPos = ( lastPos - text.length() + 1 < 0 ) || ( lastPos - text.length() + 1 > 2500000 ) ? 0 : lastPos - text.length() + 1;
//cout << lastPos << endl;
}
cout << line << endl;
}
int main ( void )
{
int n, i;
char bug[1010];
char tmp;
string line;
string text;
while ( scanf ( "%d %s%c", &n, bug, &tmp ) == 3 )
{
text = string ( bug );
for ( i = 0; i < n; i++ )
{
getline ( cin, line );
analyseLine ( text, line );
}
}
return 0;
}