include cstdio include iostream include string using namespace std int

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main (void)
{
string s, s1, s2;
int i, g;
char c;
getline (cin, s1);
if (s1=="") s1=" ";
getline (cin, s2);
if (s2=="") s2=" ";
i=0;
while (getline(cin , s))
{
g=0;
while ((i=s.find (s1, i+g*s2.length()))!=string::npos)
{
s.erase (i, s1.length());
s.insert (i, s2);
g=1;
}
cout << s << endl;;
}
return 0;
}