首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
18132254984
2026年3月19日 17:10
字符串替换 题解:
P2011
回复 0
|
赞 0
|
浏览 2
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; for(int i=0;i<s.size();i++){ if(s[i]>='A'&&s[i]<='Z'){ s[i...
xsw
2026年3月19日 08:43
字符串替换 题解:
P2011
回复 0
|
赞 0
|
浏览 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 >&g...
ez008
2026年3月15日 00:05
字符串替换 题解:
P2011
回复 0
|
赞 4
|
浏览 124
递归 #include <iostream> #include <string> using namespace std; //换为小写 string xx_s(string s){ for(int i=0;i<s.length();i++){ if(s[i]>='A'&&s[i]<='Z'){ &...
liux662
2026年3月13日 11:32
字符串替换 KMP+tolower题解:
P2011
回复 0
|
赞 0
|
浏览 68
#include<bits/stdc++.h> using namespace std; int main() { bool flag = false; string s1 = "tantan"; vector<int> moshi(6, 0); for(int i = 1; i < 6; i ++){ int j = moshi[i - 1]; while(j > 0 && s1[i] != s1[j]) j = moshi[j - 1]; if(moshi[i] == moshi[j]) ...
19385567108
2026年3月11日 14:38
字符串替换 题解:
P2011
回复 0
|
赞 4
|
浏览 79
#include<bits/stdc++.h> using namespace std; int main(){ string s,a,b; cin>>s; a="tantan"; b="baibai"; int len1=s.length(); int len2=a.size(); ...
AORIE
2026年3月4日 16:37
字符串替换 题解:
P2011
回复 0
|
赞 17
|
浏览 283
补充一个C的,库函数看不懂自己豆包一下 #include <stdio.h> #include <string.h> int isTarget(char *s) { char k[]="tantan"; return strncmp(s,k,6)==0; } void Replace(char *s,int i){ s[i] ='b'; &...
yauqq
2026年1月30日 15:51
字符串替换 题解:
P2011
回复 0
|
赞 17
|
浏览 365
#include<bits/stdc++.h> using namespace std; int main(){ string str; getline(cin, str); for(char &c:str){ c = tolower(c); } if(str.find("tantan") == string::npos) cout << "not find" <<endl; else{ while(str.find("tantan")!= string::npos){ int p...
阿灿
2025年3月15日 23:40
字符串替换 题解:find+replace
P2011
回复 0
|
赞 15
|
浏览 1.2k
#include<bits/stdc++.h> using namespace std; int main(){ string str; int flag=0; cin>>str; transform(str.begin(), str.end(),str.begin(),::tolower); while(str.find("tantan")!=string::npos){ str.replace(str.find("tantan"),6,"baibai"); flag =1; } if(flag){ cout...
kbgimf
2024年7月12日 20:15
字符串替换 题解:
P2011
回复 1
|
赞 20
|
浏览 1.5k
#include<stdio.h> #include<string.h> char s[10000]; char a[6]={'T','A','N','T','A','N'}; char b[6]={'t','a','n','t','a','n'}; char c[6]={'b','a','i','b'...
18132254984
2024年6月28日 20:55
字符串替换 题解:find + replace详细版
P2011
回复 0
|
赞 43
|
浏览 1.5k
字符串函数处理比较简单,双指针容易错,find(字符串)是返回该字符串在原字符串的下标,replace()的三个参数是需要替换的下标、被替换字符串的长度、新的字符串 string& replace (size_t pos, size_t len, const string& str); 1 参数说明: pos : 起始位置(即要替换的子串在原字符串中的起始位置)。 len : 要被替换的子串的长度。 str : 替换后的新字符串。 #include <iostream> #include <...
1
2
题目
字符串替换
题解数量
15
发布题解
在线答疑
热门题解
1
字符串替换 题解:find + replace详细版
2
字符串替换 题解:
3
字符串替换 题解:
4
字符串替换 题解:
5
字符串替换 题解:find+replace
6
字符串替换 题解:
7
字符串替换 题解:
8
字符串替换 题解:C++ find()、replace()实现
9
字符串替换 题解:
10
字符串替换 题解: