查找字符串字串并替换怎么写,为什么我的超时了?
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a,b,c;
getline(cin,a);
getline(cin,b);
getline(cin,c);
int pos;
pos = a.find(b);
while(pos != -1)
{
a.replace(pos , b.length(), c);
pos = a.find(b);
}
cout<<a<<endl;
return 0;
}