文章

82

粉丝

2

获赞

559

访问

22.0k

头像
字符串替换 题解:
P2011
发布于2026年3月19日 08:43
阅读数 12

#include<iostream>

using namespace std;
	
string change(string s) {
	string res;
	for (int i = 0; i < s.size(); i ++ ) {
		if (s[i] >= 'A' && s[i] <= 'Z')
			res += (s[i] + 32);
		else res += s[i];
	}
	return res;
}

int main() {
	
	string s;
	cin >> s;
	string res;
	bool flag = false;
	for (int i = 0; i < s.size(); i ++ ) {
		if (change(s.substr(i, 6)) == "tantan") {
			res += "baibai";
			i += 5;
			flag = true;
		} else {
			res += s[i];
		}
	}
	if (!flag) {
		cout << "not find" << endl;
	} else {
		cout << change(res) << endl;
	}
	
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发