文章
6
粉丝
43
获赞
41
访问
4.3k
看不懂的话就用双重循环吧~,如果有多个tantan,
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
string sp = "baibai";
bool isExact = false;
cin>>s;
for(auto &ss : s){
ss = tolower(ss);
}
//Find the all position of "tantan"
for(int i = 0;i < s.size();i++){
for(int j = 0;j < s.size();j++){
if(s.substr(i, j - i + 1) == "tantan"){
isExact = true;
for(int k = i;k <= j;k++){
s[k] = sp[k-i];
}
}
}
}
if(isExact){
cout<<s<<endl;
}
else{
cout<<"not find"<<endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发