- 查找子串且替换
- @ 2026-05-23 12:43:58
#include<bits/stdc++.h>
using namespace std;
string s1,st,sc;
int main( )
{
cin>>s1>>sc>>st;
int x=s1.find(sc);
s1.replace(x,st.size(),st);
cout<<s1;
return 0;
}
5 条评论
-
202603zj08王宇浩 (王宇浩) LV 8 @ 2026-05-23 13:00:05
#include<bits/stdc++.h> using namespace std; string s1,st,sc; int main( ) { getline(cin,s1); cin>>sc>>st; int x=s1.find(sc); s1.replace(x,st.size(),st); cout<<s1; return 0; } -
@ 2026-05-23 12:58:04
逗号
-
@ 2026-05-23 12:57:43
#include<bits/stdc++.h> using namespace std; int main() { getline(cin,s); return 0; } -
@ 2026-05-23 12:57:00
#include<bits/stdc++.h> using namespace std; string s1,st,sc; int main( ) { getline(cin>>s1); cin>>sc>>st; int x=s1.find(sc); s1.replace(x,st.size(),st); cout<<s1; return 0; } -
@ 2026-05-23 12:48:19
输入有空格的话,要用
getline(cin>>s);
- 1
信息
- ID
- 1006
- 难度
- 5
- 分类
- (无)
- 标签
- 递交数
- 189
- 已通过
- 69
- 通过率
- 37%
- 被复制
- 7
- 上传者