首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
408真题
专业课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
阿灿
2025年3月15日 23:40
字符串替换 题解:find+replace
P2011
回复 0
|
赞 4
|
浏览 272
#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
|
赞 9
|
浏览 700
#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'...
18919717626
2024年6月28日 20:55
字符串替换 题解:find + replace详细版
P2011
回复 0
|
赞 16
|
浏览 644
字符串函数处理比较简单,双指针容易错,find(字符串)是返回该字符串在原字符串的下标,replace()的三个参数是需要替换的下标、被替换字符串的长度、新的字符串 string& replace (size_t pos, size_t len, const string& str); 1 参数说明: pos : 起始位置(即要替换的子串在原字符串中的起始位置)。 len : 要被替换的子串的长度。 str : 替换后的新字符串。 #include <iostream> #include <...
雨梦のkira
2024年3月26日 19:20
字符串替换 题解:
P2011
回复 0
|
赞 2
|
浏览 571
看不懂的话就用双重循环吧~,如果有多个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.siz...
Cookie‘s AE86
2024年3月26日 15:54
字符串替换 题解:C++ find()、replace()实现
P2011
回复 0
|
赞 2
|
浏览 684
#include<bits/stdc++.h> using namespace std; int main (){ string s; cin >> s; transform(s.begin(), s.end(),s.begin() ,::tolower); int index = s.find("tantan", index); if(index == -1){ cout << "not find" << endl; return 0; ...
望雨天
2024年3月22日 10:10
字符串替换 题解:
P2011
回复 0
|
赞 1
|
浏览 612
#include<iostream> #include<string> using namespace std; int main(){ string s; string to = "baibai"; cin>>s; //首先使用tolower()将输入字符串转换为小写。toupper()转换大写 for(int i=0;i<s.size();i++){ ...
1071512987
2024年3月11日 21:52
字符串替换 题解:
P2011
回复 0
|
赞 0
|
浏览 720
java语言,调用String自带函数 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String inStr = in.nextLine();  ...
0980石神
2023年6月28日 17:15
字符串替换 题解:
P2011
回复 0
|
赞 4
|
浏览 1.1k
#include <bits/stdc++.h> using namespace std; int main() { char a[105]={0};//初始串 char b[105]={0};//全部小写串 char c[105]={0};//结果 char x[105] = {'t','a','n','t','a','n'}; &nb...
题目
字符串替换
题解数量
8
发布题解
在线答疑
热门题解
1
字符串替换 题解:find + replace详细版
2
字符串替换 题解:
3
字符串替换 题解:find+replace
4
字符串替换 题解:
5
字符串替换 题解:C++ find()、replace()实现
6
字符串替换 题解:
7
字符串替换 题解:
8
字符串替换 题解: