include iostream using namespace std int main string from to getline c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
int main()
{
string from,to;
getline(cin,from);
getline(cin,to);
string line;
while(getline(cin,line))
{
if (from!=to)
{
int lastpos = 0;
while ((lastpos=line.find(from, lastpos))!=string::npos)
{
line.replace(lastpos,from.length(),to);
lastpos+=from.length();
}
}
cout << line << endl;
}
}