📄 4.12.cpp
字号:
#include <iostream>
#include <string>
using namespace std;
void Replace(string& S,string T,string V);
int main()
{
string s,t,v;
cin >> s >> t >> v;
Replace(s,t,v);
cout << s;
system("pause");
return 0;
}
void Replace(string& S,string T,string V)
{
char temp[100] = {'\0'};
int mark = 0;
int i = 0;
int j = 0;
bool is_success;
while(S[i] != '\0')
{
is_success = true;
int j = i;
for(int s=0; T[s]!='\0';s++)
{
if(S[j] == T[s])
j++;
else
{is_success = false;break;}
}
if(!is_success)
temp[mark++] = S[i++];
else
{
for(int m=0; V[m]!='\0'; m++)
temp[mark++] = V[m];
i = j;
}
}
S = temp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -