string a;/////指定串,可根据要求替换
 string b;////要查找的串,可根据要求替换
 string c;
 cin>>a>>b>>c;
 int pos;
 pos = a.find(b);////查找指定的串
 while (pos != -1)
 {
  a.replace(pos,b.length(),c);////用新的串替换掉指定的串

  pos = a.find(b);//////继续查找指定的串,直到所有的都找到为止
 }
 cout<<a<<endl;

相关文章:

  • 2021-07-30
  • 2021-11-04
  • 2021-09-03
  • 2021-12-24
  • 2022-01-09
  • 2021-06-20
  • 2021-10-10
猜你喜欢
  • 2021-09-06
  • 2021-09-14
  • 2022-12-23
  • 2021-12-14
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案