删除字符串 题解: replace与find函数
#include<iostream>
#include<string>
using namespace std;
int main() {
string str;
getline(cin, str);
string s = "gzu";
int m = s.length();
while (str.find(s)!=string::npos) {
int find = str.find(s);
str.replace(find,m,"");
}
cout << str;
return 0;
}
登录后发布评论
暂无评论,来抢沙发