字符串-02. 删除字符串中的子串(20)

来源:互联网 发布:java软件编程培训机构 编辑:程序博客网 时间:2024/05/16 02:36

来源:http://blog.csdn.net/u012796532/article/details/38488725

C++实现起来好简单,方便。。要熟练掌握C++中string的各种常用操作。。

#include <string>  #include <iostream>  using namespace std;  int main()  {      string s1,s2;      getline(cin,s1);      getline(cin,s2);      while(s1.find(s2)!=string::npos)          s1.erase(s1.find(s2),s2.length());      cout<<s1<<endl;      return 0;  } 


0 0